(gmp.info.gz) Converting Floats
Info Catalog
(gmp.info.gz) Simultaneous Float Init & Assign
(gmp.info.gz) Floating-point Functions
(gmp.info.gz) Float Arithmetic
Conversion Functions
====================
- Function: double mpf_get_d (mpf_t OP)
Convert OP to a `double', truncating if necessary (ie. rounding
towards zero).
If the exponent in OP 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: double mpf_get_d_2exp (signed long int *EXP, mpf_t OP)
Convert OP to a `double', truncating if necessary (ie. rounding
towards zero), and with an exponent returned separately.
The return value is in the range 0.5<=abs(D)<1 and the exponent is
stored to `*EXP'. D * 2^EXP is the (truncated) OP value. If OP
is zero, the return is 0.0 and 0 is stored to `*EXP'.
This is similar to the standard C `frexp' function (
Normalization Functions (libc)Normalization Functions.).
- Function: long mpf_get_si (mpf_t OP)
- Function: unsigned long mpf_get_ui (mpf_t OP)
Convert OP to a `long' or `unsigned long', truncating any fraction
part. If OP is too big for the return type, the result is
undefined.
See also `mpf_fits_slong_p' and `mpf_fits_ulong_p' (
Miscellaneous Float Functions).
- Function: char * mpf_get_str (char *STR, mp_exp_t *EXPPTR, int BASE,
size_t N_DIGITS, mpf_t OP)
Convert OP to a string of digits in base BASE. BASE can be 2 to
36. Up to N_DIGITS digits will be generated. Trailing zeros are
not returned. No more digits than can be accurately represented
by OP are ever generated. If N_DIGITS is 0 then that accurate
maximum number of digits are generated.
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 N_DIGITS + 2
bytes, that being enough for the mantissa, a possible minus sign,
and a null-terminator. When N_DIGITS is 0 to get all significant
digits, an application won't be able to know the space required,
and STR should be `NULL' in that case.
The generated string is a fraction, with an implicit radix point
immediately to the left of the first digit. The applicable
exponent is written through the EXPPTR pointer. For example, the
number 3.1416 would be returned as string "31416" and exponent 1.
When OP is zero, an empty string is produced and the exponent
returned is 0.
A pointer to the result string is returned, being either the
allocated block or the given STR.
Info Catalog
(gmp.info.gz) Simultaneous Float Init & Assign
(gmp.info.gz) Floating-point Functions
(gmp.info.gz) Float Arithmetic
automatically generated byinfo2html