(gmp.info.gz) Rational Conversions
Info Catalog
(gmp.info.gz) Initializing Rationals
(gmp.info.gz) Rational Number Functions
(gmp.info.gz) Rational Arithmetic
Conversion Functions
====================
- Function: double mpq_get_d (mpq_t OP)
Convert OP to a `double', truncating if necessary (ie. rounding
towards zero).
If the exponent from the conversion is too big or too small to fit
a `double' then the result is system dependent. For too big an
infinity is returned when available. For too small 0.0 is
normally returned. Hardware overflow, underflow and denorm traps
may or may not occur.
- Function: void mpq_set_d (mpq_t ROP, double OP)
- Function: void mpq_set_f (mpq_t ROP, mpf_t OP)
Set ROP to the value of OP. There is no rounding, this conversion
is exact.
- Function: char * mpq_get_str (char *STR, int BASE, mpq_t OP)
Convert OP to a string of digits in base BASE. The base may vary
from 2 to 36. The string will be of the form `num/den', or if the
denominator is 1 then just `num'.
If STR is `NULL', the result string is allocated using the current
allocation function ( Custom Allocation). The block will be
`strlen(str)+1' bytes, that being exactly enough for the string and
null-terminator.
If STR is not `NULL', it should point to a block of storage large
enough for the result, that being
mpz_sizeinbase (mpq_numref(OP), BASE)
+ mpz_sizeinbase (mpq_denref(OP), BASE) + 3
The three extra bytes are for a possible minus sign, possible
slash, and the null-terminator.
A pointer to the result string is returned, being either the
allocated block, or the given STR.
Info Catalog
(gmp.info.gz) Initializing Rationals
(gmp.info.gz) Rational Number Functions
(gmp.info.gz) Rational Arithmetic
automatically generated byinfo2html