DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK

# (gmp.info.gz) Float Comparison

Info Catalog (gmp.info.gz) Float Arithmetic (gmp.info.gz) Floating-point Functions (gmp.info.gz) I/O of Floats
```
Comparison Functions
====================

- Function: 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)
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 (mpf_t OP1, mpf_t OP2, unsigned long int 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: 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).

- Function: void mpf_reldiff (mpf_t ROP, mpf_t OP1, 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 (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 arguments multiple times.

```
Info Catalog (gmp.info.gz) Float Arithmetic (gmp.info.gz) Floating-point Functions (gmp.info.gz) I/O of Floats
automatically generated byinfo2html