Go to the first, previous, next, last section, table of contents.
- Function: double mpq_get_d (mpq_t op)
-
Convert op to a double.
- Function: void mpq_set_d (mpq_t rop, double d)
-
Set rop to the value of d, without rounding.
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))
.
Go to the first, previous, next, last section, table of contents.