Copyright (C) 2000-2012 |
GNU Info (gmp.info)Converting FloatsConversion Functions ==================== - Function: double mpf_get_d (mpf_t OP) Convert OP to a `double'. - Function: double mpf_get_d_2exp (signed long int EXP, mpf_t OP) Find D and EXP such that D times 2 raised to EXP, with 0.5<=abs(D)<1, is a good approximation to OP. This is similar to the standard C function `frexp'. - 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' (Note: 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 (Note: 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. automatically generated by info2www version 1.2.2.9 |