manpagez: man pages & more
info gmp
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6 Comparison Functions

Function: int mpf_cmp (const mpf_t op1, const mpf_t op2)
Function: int mpf_cmp_d (const mpf_t op1, double op2)
Function: int mpf_cmp_ui (const mpf_t op1, unsigned long int op2)
Function: int mpf_cmp_si (const mpf_t op1, signed long int op2)

Compare op1 and op2. Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.

mpf_cmp_d can be called with an infinity, but results are undefined for a NaN.

Function: int mpf_eq (const mpf_t op1, const mpf_t op2, mp_bitcnt_t op3)

Return non-zero if the first op3 bits of op1 and op2 are equal, zero otherwise. I.e., test if op1 and op2 are approximately equal.

Caution 1: All version of GMP up to version 4.2.4 compared just whole limbs, meaning sometimes more than op3 bits, sometimes fewer.

Caution 2: This function will consider XXX11...111 and XX100...000 different, even if ... is replaced by a semi-infinite number of bits. Such numbers are really just one ulp off, and should be considered equal.

Function: void mpf_reldiff (mpf_t rop, const mpf_t op1, const mpf_t op2)

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

Macro: int mpf_sgn (const mpf_t op)

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 argument multiple times.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on March 31, 2014 using texi2html 5.0.

© 2000-2019
Individual documents may contain additional copyright information.