diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2021-03-08 16:17:11 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2021-03-08 16:17:11 +0000 |
commit | bc61e88db460c60575b3beea38dfa29fd568bf82 (patch) | |
tree | a945c086f4db895af9c1c6aaf9ea0c403719af2a /tests/tset_sj.c | |
parent | 10fc2966643aa9e3aaf9edb875a78665532c56ac (diff) | |
download | mpfr-bc61e88db460c60575b3beea38dfa29fd568bf82.tar.gz |
[tests/{tset_si.c,tset_sj.c}] Fix when -DMPFR_USE_NO_MACRO is used.
The mpfr_get_exp() function checks that the argument is a regular
number, but the corresponding macro doesn't. The test code was
calling mpfr_get_exp() on 0, thus failed with MPFR_USE_NO_MACRO
defined. Here, the code was correct with the macro, because the
value was not used for the particular case 0.
This is fixed by testing 0 earlier (and doing a goto, but the code
has fewer tests and should be simpler to understand). Moreover,
mpfr_get_exp has been replaced by MPFR_GET_EXP, so that the argument
is checked with --enable-assert.
git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14464 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tset_sj.c')
-rw-r--r-- | tests/tset_sj.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/tset_sj.c b/tests/tset_sj.c index 0c0e731dc..68ebe85b6 100644 --- a/tests/tset_sj.c +++ b/tests/tset_sj.c @@ -225,27 +225,29 @@ test_2exp_extreme_aux (void) power of 2 is exact, unless underflow/overflow occurs. The tests on the exponent below avoid integer overflows (ep[i] may take extreme values). */ - e = mpfr_get_exp (x1); mpfr_clear_flags (); - if (j != 0 && ep[i] < __gmpfr_emin - e) /* underflow */ + if (j == 0) + goto zero; + e = MPFR_GET_EXP (x1); + if (ep[i] < __gmpfr_emin - e) /* underflow */ { mpfr_rnd_t r = (rnd == MPFR_RNDN && - (ep[i] < __gmpfr_emin - mpfr_get_exp (y) - 1 || + (ep[i] < __gmpfr_emin - MPFR_GET_EXP (y) - 1 || IS_POW2 (sign * j))) ? MPFR_RNDZ : (mpfr_rnd_t) rnd; inex1 = mpfr_underflow (x1, r, sign); flags1 = __gmpfr_flags; } - else if (j != 0 && ep[i] > __gmpfr_emax - e) /* overflow */ + else if (ep[i] > __gmpfr_emax - e) /* overflow */ { inex1 = mpfr_overflow (x1, (mpfr_rnd_t) rnd, sign); flags1 = __gmpfr_flags; } else { - if (j != 0) - mpfr_set_exp (x1, ep[i] + e); + mpfr_set_exp (x1, ep[i] + e); + zero: flags1 = inex1 != 0 ? MPFR_FLAGS_INEXACT : 0; } } |