A header file mpf2mpfr.h is included in the distribution of MPFR for
compatibility with the GNU MP class MPF.
After inserting the following two lines after the #include <gmp.h>
line,
#include <mpfr.h> #include <mpf2mpfr.h>any program written for MPF can be compiled directly with MPFR without any changes. All operations are then performed with the default MPFR rounding mode, which can be reset with
mpfr_set_default_rounding_mode
.
Warning: the mpf_init
and mpf_init2
functions initialize
to zero, whereas the corresponding MPFR functions initialize to NaN:
this is useful to detect uninitialized values, but is slightly incompatible
with mpf
.
Reset the precision of x to be exactly prec bits. The only difference with
mpfr_set_prec
is that prec is assumed to be small enough so that the significand fits into the current allocated memory space for x. Otherwise the behavior is undefined.
Return non-zero if op1 and op2 are both non-zero ordinary numbers with the same exponent and the same first op3 bits, both zero, or both infinities of the same sign. Return zero otherwise. This function is defined for compatibility with
mpf
. Do not use it if you want to know whether two numbers are close to each other; for instance, 1.011111 and 1.100000 are currently regarded as different for any value of op3 larger than 1 (but this may change in the next release).
Compute the relative difference between op1 and op2 and store the result in rop. This function does not guarantee the correct rounding on the relative difference; it just computes |op1-op2|/op1, using the rounding mode rnd for all operations and the precision of rop.