mpfr
conversion functionsThe functions described in this section convert between mpfr
numbers and character strings, naturals, or standard IEEE floating
point format (in their list representations). Where these functions
have similar or equivalent counterparts in the mpfr
library's
native API, the names have been changed for mnemonic reasons.
dbl2mp
mpfr
number equal to the input with a
fixed precision, currently set to 160 bits.
mp2dbl
mpfr
number, and the output is the best
possible approximation to it by a standard a double precision
number.
str2mp
(
prec,
s)
, where prec is a
natural number specifying the precision, and s is a string
expressing a floating point number in C format. The output is an
mpfr
number with the specified precision.
mp2str
mpfr
number, and the output is a character
string expressing the number in exponential decimal notation.
Sufficiently many decimal digits are included in the string to express
the full precision.
nat2mp
mpfr
number of sufficient precision to
express the natural number exactly.
The mp2str
function enhances the native mpfr_get_str
function by properly formatting the output string rather than only
listing the digits of the mantissa.
The nat2mp
function does not rely on the mpfr
native
integer conversion functions, so natural numbers with any number of
bits up to MP_PREC_MAX
can be used losslessly. There is
currently no conversion in the other direction.