Node:Float Comparison, Next:, Previous:Float Arithmetic, Up:Floating-point Functions



Comparison Functions

int mpf_cmp (mpf_t op1, mpf_t op2) Function
int mpf_cmp_d (mpf_t op1, double op2) Function
int mpf_cmp_ui (mpf_t op1, unsigned long int op2) Function
int mpf_cmp_si (mpf_t op1, signed long int op2) Function
Compare op1 and op2. Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.

int mpf_eq (mpf_t op1, mpf_t op2, unsigned long int op3) Function
Return non-zero if the first op3 bits of op1 and op2 are equal, zero otherwise. I.e., test of op1 and op2 are approximately equal.

Caution: Currently only whole limbs are compared, and only in an exact fashion. In the future values like 1000 and 0111 may be considered the same to 3 bits (on the basis that their difference is that small).

void mpf_reldiff (mpf_t rop, mpf_t op1, mpf_t op2) Function
Compute the relative difference between op1 and op2 and store the result in rop. This is abs(op1-op2)/op1.

int mpf_sgn (mpf_t op) Macro
Return +1 if op > 0, 0 if op = 0, and -1 if op < 0.

This function is actually implemented as a macro. It evaluates its arguments multiple times.