A header file mpf2mpfr.h is included in the distribution of MPFR for
compatibility with the GNU MP class MPF.
By 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 (except the
gmp_printf
functions will not work for arguments of type
mpfr_t
).
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, we do not recommend to use it otherwise. Do not use it either if you want to know whether two numbers are close to each other; for instance, 1.011111 and 1.100000 are regarded as different for any value of op3 larger than 1.
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 precision of rop and the rounding mode rnd for all operations.
These functions are identical to
mpfr_mul_2ui
andmpfr_div_2ui
respectively. These functions are only kept for compatibility with MPF, one should prefermpfr_mul_2ui
andmpfr_div_2ui
otherwise.