Next: Basic Arithmetic Functions, Previous: Combined Initialization and Assignment Functions, Up: MPFR Interface
Convert op to a
double
(respectively_Decimal64
orlong double
), using the rounding mode rnd. If op is NaN, some fixed NaN (either quiet or signaling) or the result of 0.0/0.0 is returned. If op is ±Inf, an infinity of the same sign or the result of ±1.0/0.0 is returned. If op is zero, these functions return a zero, trying to preserve its sign, if possible. Thempfr_get_decimal64
function is built only under some conditions: see the documentation ofmpfr_set_decimal64
.
Return d and set exp such that 0.5<=abs(d)<1 and d times 2 raised to exp equals op rounded to double (resp. long double) precision, using the given rounding mode. If op is zero, then a zero of the same sign (or an unsigned zero, if the implementation does not have signed zeros) is returned, and exp is set to 0. If op is NaN or an infinity, then the corresponding double precision (resp. long-double precision) value is returned, and exp is undefined.
Convert op to a
long
, anunsigned long
, anintmax_t
or anuintmax_t
(respectively) after rounding it with respect to rnd. If op is NaN, the result is undefined. If op is too big for the return type, it returns the maximum or the minimum of the corresponding C type, depending on the direction of the overflow. The erange flag is set too. See alsompfr_fits_slong_p
,mpfr_fits_ulong_p
,mpfr_fits_intmax_p
andmpfr_fits_uintmax_p
.
Put the scaled significand of op (regarded as an integer, with the precision of op) into rop, and return the exponent exp (which may be outside the current exponent range) such that op exactly equals rop multiplied by two exponent exp. If the exponent is not representable in the
mp_exp_t
type, the behavior is undefined.
Convert op to a
mpz_t
, after rounding it with respect to rnd. If op is NaN or Inf, the result is undefined.
Convert op to a
mpf_t
, after rounding it with respect to rnd. Return zero iff no error occurred, in particular a non-zero value is returned if op is NaN or Inf, which do not exist inmpf
.
Convert op to a string of digits in base b, with rounding in the direction rnd, where n is either zero (see below) or the number of significant digits; in the latter case, n must be greater or equal to 2. The base may vary from 2 to 36.
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. If rnd is to nearest, and op is exactly in the middle of two possible outputs, the one with an even last digit is chosen (for an odd base, this may not correspond to an even significand).
If n is zero, the number of digits of the significand is chosen large enough so that re-reading the printed value with the same precision, assuming both output and input use rounding to nearest, will recover the original value of op. More precisely, in most cases, the chosen precision of str is the minimal precision depending on n and b only that satisfies the above property, i.e., m = 1 + ceil(n*log(2)/log(b)), but in some very rare cases, it might be m+1.
If str is a null pointer, space for the significand is allocated using the current allocation function, and a pointer to the string is returned. To free the returned string, you must use
mpfr_free_str
.If str is not a null pointer, it should point to a block of storage large enough for the significand, i.e., at least
max(
n+ 2, 7)
. The extra two bytes are for a possible minus sign, and for the terminating null character.If the input number is an ordinary number, the exponent is written through the pointer expptr (the current minimal exponent for 0).
A pointer to the string is returned, unless there is an error, in which case a null pointer is returned.
Free a string allocated by
mpfr_get_str
using the current unallocation function (preliminary interface). The block is assumed to bestrlen(
str)+1
bytes. For more information about how it is done: see Section “Custom Allocation” in GNU MP.
Return non-zero if op would fit in the respective C data type, when rounded to an integer in the direction rnd.