Go to the first, previous, next, last section, table of contents.


Conversion 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. The base may vary from 2 to 36. Generate at most n_digits significant digits, or if n_digits is 0, the maximum number of digits accurately representable by op.

If str is NULL, space for the mantissa is allocated using the default allocation function, and a pointer to the string is returned.

If str is not NULL, it should point to a block of storage enough large for the mantissa, i.e., n_digits + 2. The two extra bytes are for a possible minus sign, and for the terminating null character.

The exponent is written through the pointer expptr.

If n_digits is 0, the maximum number of digits meaningfully achievable from the precision of op will be generated. Note that the space requirements for str in this case will be impossible for the user to predetermine. Therefore, you need to pass NULL for the string argument whenever n_digits is 0.

The generated string is a fraction, with an implicit radix point immediately to the left of the first digit. For example, the number 3.1416 would be returned as "31416" in the string and 1 written at expptr.


Go to the first, previous, next, last section, table of contents.