summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-07-15 14:17:12 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-07-15 14:17:12 +0000
commit9611c872cafe83a71c8931c990187ea0443c7952 (patch)
tree87c903de576b6d04b3a70e2d64828d04e4e59ea7
parent1e88edcf7cb78cc454a39e6d1f2b204c218b5b04 (diff)
downloadmpfr-9611c872cafe83a71c8931c990187ea0443c7952.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. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9616 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/div_2si.c3
-rw-r--r--src/div_2ui.c4
-rw-r--r--src/mul_2si.c3
3 files changed, 7 insertions, 3 deletions
diff --git a/src/div_2si.c b/src/div_2si.c
index 4220bcfae..140713f92 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));
}