[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.14 Compatibility With MPF
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
.
- Function: void mpfr_set_prec_raw (mpfr_t x, mp_prec_t prec)
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.
- Function: int mpfr_eq (mpfr_t op1, mpfr_t op2, unsigned long int op3)
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 regarded as different for any value of op3 larger than 1.
- Function: void mpfr_reldiff (mpfr_t rop, mpfr_t op1, mpfr_t op2, mp_rnd_t rnd)
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.
- Function: int mpfr_mul_2exp (mpfr_t rop, mpfr_t op1, unsigned long int op2, mp_rnd_t rnd)
- Function: int mpfr_div_2exp (mpfr_t rop, mpfr_t op1, unsigned long int op2, mp_rnd_t rnd)
See
mpfr_mul_2ui
andmpfr_div_2ui
. These functions are only kept for compatibility with MPF.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |