diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-07-17 00:26:03 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-07-17 00:26:03 +0000 |
commit | 210e6b5e4aa5bd17a6bf7555a7427a61a34c5c0b (patch) | |
tree | 1d521b8f4b4be2380cc50c2f0a4615bd8ab465a9 /src | |
parent | efa390ebecd6cbaa0315fe4062899acfe52a9314 (diff) | |
download | mpfr-210e6b5e4aa5bd17a6bf7555a7427a61a34c5c0b.tar.gz |
[src/{div_2si.c,div_2ui.c,mul_2si.c}] Fixed some underflow cases in
rounding to nearest when the exact result is -2^(emin-2), i.e. the
middle of 0 and the minimum negative number in absolute value (the
correction in r5517 was incorrect/incomplete).
[tests/tmul_2exp.c] Extended the underflow() test to negative numbers,
triggering the bug fixed here.
(merged changesets r9614,9616 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@9620 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src')
-rw-r--r-- | src/div_2si.c | 3 | ||||
-rw-r--r-- | src/div_2ui.c | 4 | ||||
-rw-r--r-- | src/mul_2si.c | 3 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/div_2si.c b/src/div_2si.c index 0a86b79f2..b73309419 100644 --- a/src/div_2si.c +++ b/src/div_2si.c @@ -45,7 +45,8 @@ mpfr_div_2si (mpfr_ptr y, mpfr_srcptr x, long int n, mpfr_rnd_t rnd_mode) if (rnd_mode == MPFR_RNDN && (__gmpfr_emin > MPFR_EMAX_MAX - (n - 1) || exp < __gmpfr_emin + (n - 1) || - (inexact >= 0 && mpfr_powerof2_raw (y)))) + ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) && + mpfr_powerof2_raw (y)))) rnd_mode = MPFR_RNDZ; return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y)); } diff --git a/src/div_2ui.c b/src/div_2ui.c index 3aa8b6ae8..e548744d0 100644 --- a/src/div_2ui.c +++ b/src/div_2ui.c @@ -44,7 +44,9 @@ mpfr_div_2ui (mpfr_ptr y, mpfr_srcptr x, unsigned long n, mpfr_rnd_t rnd_mode) if (MPFR_UNLIKELY (n >= diffexp)) /* exp - n <= emin - 1 */ { if (rnd_mode == MPFR_RNDN && - (n > diffexp || (inexact >= 0 && mpfr_powerof2_raw (y)))) + (n > diffexp || + ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) && + mpfr_powerof2_raw (y)))) rnd_mode = MPFR_RNDZ; return mpfr_underflow (y, rnd_mode, MPFR_SIGN (y)); } diff --git a/src/mul_2si.c b/src/mul_2si.c index 0b02e2940..bc5e47934 100644 --- a/src/mul_2si.c +++ b/src/mul_2si.c @@ -48,7 +48,8 @@ mpfr_mul_2si (mpfr_ptr y, mpfr_srcptr x, long int n, mpfr_rnd_t rnd_mode) if (rnd_mode == MPFR_RNDN && (__gmpfr_emin > MPFR_EMAX_MAX + (n + 1) || exp < __gmpfr_emin - (n + 1) || - (inexact >= 0 && mpfr_powerof2_raw (y)))) + ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) && + mpfr_powerof2_raw (y)))) rnd_mode = MPFR_RNDZ; return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y)); } |