Go forward to Applying Integer Functions.
Go backward to Assigning Rationals.
Go up to Rational Number Functions.
Comparison Functions
====================
- Function: int mpq_cmp (mpq_t OP1, mpq_t OP2)
Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero
if OP1 = OP2, and a negative value if OP1 < OP2.
To determine if two rationals are equal, `mpq_equal' is faster than
`mpq_cmp'.
- Macro: int mpq_cmp_ui (mpq_t OP1, unsigned long int NUM2, unsigned
long int DEN2)
Compare OP1 and NUM2/DEN2. Return a positive value if OP1 >
NUM2/DEN2, zero if OP1 = NUM2/DEN2, and a negative value if OP1 <
NUM2/DEN2.
This routine allows that NUM2 and DEN2 have common factors.
This function is actually implemented as a macro. It evaluates its
arguments multiple times.
- Macro: int mpq_sgn (mpq_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.
- Function: int mpq_equal (mpq_t OP1, mpq_t OP2)
Return non-zero if OP1 and OP2 are equal, zero if they are
non-equal. Although `mpq_cmp' can be used for the same purpose,
this function is much faster.