[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.1 Type and Macro Changes
The official type for exponent values changed from mp_exp_t
to
mpfr_exp_t
in MPFR 3.0. The type mp_exp_t
will remain
available as it comes from GMP (with a different meaning). These types
are currently the same (mpfr_exp_t
is defined as mp_exp_t
with typedef
), so that programs can still use mp_exp_t
;
but this may change in the future.
Alternatively, using the following code after including ‘mpfr.h’
will work with official MPFR versions, as mpfr_exp_t
was never
defined in MPFR 2.x:
#if MPFR_VERSION_MAJOR < 3 typedef mp_exp_t mpfr_exp_t; #endif |
The official types for precision values and for rounding modes
respectively changed from mp_prec_t
and mp_rnd_t
to mpfr_prec_t
and mpfr_rnd_t
in MPFR 3.0. This
change was actually done a long time ago in MPFR, at least since
MPFR 2.2.0, with the following code in ‘mpfr.h’:
#ifndef mp_rnd_t # define mp_rnd_t mpfr_rnd_t #endif #ifndef mp_prec_t # define mp_prec_t mpfr_prec_t #endif |
This means that it is safe to use the new official types
mpfr_prec_t
and mpfr_rnd_t
in your programs.
The types mp_prec_t
and mp_rnd_t
(defined
in MPFR only) may be removed in the future, as the prefix
mp_
is reserved by GMP.
The precision type mpfr_prec_t
(mp_prec_t
) was unsigned
before MPFR 3.0; it is now signed. MPFR_PREC_MAX
has not changed,
though. Indeed the MPFR code requires that MPFR_PREC_MAX
be
representable in the exponent type, which may have the same size as
mpfr_prec_t
but has always been signed.
The consequence is that valid code that does not assume anything about
the signedness of mpfr_prec_t
should work with past and new MPFR
versions.
This change was useful as the use of unsigned types tends to convert
signed values to unsigned ones in expressions due to the usual arithmetic
conversions, which can yield incorrect results if a negative value is
converted in such a way.
Warning! A program assuming (intentionally or not) that
mpfr_prec_t
is signed may be affected by this problem when
it is built and run against MPFR 2.x.
The rounding modes GMP_RNDx
were renamed to MPFR_RNDx
in MPFR 3.0. However the old names GMP_RNDx
have been kept for
compatibility (this might change in future versions), using:
#define GMP_RNDN MPFR_RNDN #define GMP_RNDZ MPFR_RNDZ #define GMP_RNDU MPFR_RNDU #define GMP_RNDD MPFR_RNDD |
The rounding mode “round away from zero” (MPFR_RNDA
) was added in
MPFR 3.0 (however no rounding mode GMP_RNDA
exists).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |