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/div_2ui.c | |
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/div_2ui.c')
-rw-r--r-- | src/div_2ui.c | 4 |
1 files changed, 3 insertions, 1 deletions
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)); } |