diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2014-02-11 13:18:00 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2014-02-11 13:18:00 +0000 |
commit | c673d2d6e040cd23cff109af8de8119b13c5ff4a (patch) | |
tree | 1a2899eb32019e4924482d9ff6573b7313cf2b7b /src/mpfr-impl.h | |
parent | 4a6c79009b04a646bb4e0e7e85991a3cace85c40 (diff) | |
download | mpfr-c673d2d6e040cd23cff109af8de8119b13c5ff4a.tar.gz |
Start of mpfr_set_exp behavior clean-up.
* src/mpfr-impl.h: updated the MPFR_SET_EXP(x, exp) definition for
the MPFR_EXP_CHECK case. There are 2 consequences:
1. The exp expression is evaluated several times (this should be
OK with the MPFR code and optimizations).
2. The real value of exp is tested for the assertion, instead of
the value converted to mpfr_exp_t. Thus new bugs can be found
(e.g. when an unsigned type is used instead of signed).
* src/set_exp.c: set the exponent only if x is a non-zero ordinary
number, i.e. already has a valid significand and a valid exponent
(thus it is no longer a low-level function, and it can no longer
generate an invalid value from a valid one).
* doc/mpfr.texi: updated mpfr_set_exp description and added an item
in the "API Compatibility / Changed Functions" section.
Currently 73 tests pass and 96 fail on Linux/x86_64, either due to bugs
or due to code not yet updated for this change.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/set_exp@8924 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/mpfr-impl.h')
-rw-r--r-- | src/mpfr-impl.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index 569bb8336..eee6afae2 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -784,7 +784,9 @@ typedef intmax_t mpfr_eexp_t; #ifdef MPFR_EXP_CHECK # define MPFR_GET_EXP(x) (mpfr_get_exp) (x) -# define MPFR_SET_EXP(x, exp) MPFR_ASSERTN (!mpfr_set_exp ((x), (exp))) +# define MPFR_SET_EXP(x, exp) (MPFR_ASSERTN ((exp) >= __gmpfr_emin && \ + (exp) <= __gmpfr_emax), \ + (void) (MPFR_EXP (x) = (exp))) # define MPFR_SET_INVALID_EXP(x) ((void) (MPFR_EXP (x) = MPFR_EXP_INVALID)) #else # define MPFR_GET_EXP(x) MPFR_EXP (x) |