Go backward to Applying Integer Functions.
Go up to Rational Number Functions.
Miscellaneous Functions
=======================
- Function: double mpq_get_d (mpq_t OP)
Convert OP to a double.
These functions assign between either the numerator or denominator
of a rational, and an integer. Instead of using these functions, it is
preferable to use the more general mechanisms `mpq_numref' and
`mpq_denref', together with `mpz_set'.
- Function: void mpq_set_num (mpq_t RATIONAL, mpz_t NUMERATOR)
Copy NUMERATOR to the numerator of RATIONAL. When this risks to
make the numerator and denominator of RATIONAL have common
factors, you have to pass RATIONAL to `mpq_canonicalize' before
any operations are performed on RATIONAL.
This function is equivalent to `mpz_set (mpq_numref (RATIONAL),
NUMERATOR)'.
- Function: void mpq_set_den (mpq_t RATIONAL, mpz_t DENOMINATOR)
Copy DENOMINATOR to the denominator of RATIONAL. When this risks
to make the numerator and denominator of RATIONAL have common
factors, or if the denominator might be negative, you have to pass
RATIONAL to `mpq_canonicalize' before any operations are performed
on RATIONAL.
*In version 1 of the library, negative denominators were handled by
copying the sign to the numerator. That is no longer done.*
This function is equivalent to `mpz_set (mpq_denref (RATIONAL),
DENOMINATORS)'.
- Function: void mpq_get_num (mpz_t NUMERATOR, mpq_t RATIONAL)
Copy the numerator of RATIONAL to the integer NUMERATOR, to
prepare for integer operations on the numerator.
This function is equivalent to `mpz_set (NUMERATOR, mpq_numref
(RATIONAL))'.
- Function: void mpq_get_den (mpz_t DENOMINATOR, mpq_t RATIONAL)
Copy the denominator of RATIONAL to the integer DENOMINATOR, to
prepare for integer operations on the denominator.
This function is equivalent to `mpz_set (DENOMINATOR, mpq_denref
(RATIONAL))'.