summaryrefslogtreecommitdiff
path: root/subnormal.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-10-23 02:43:39 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-10-23 02:43:39 +0000
commit91f1b7742c6d4c814311c0f85362067ed1818416 (patch)
tree49cd6a84e01213d33ecab528509c65b7117473fb /subnormal.c
parent5e01280490b0407ef8a7f85ff539d899f822dfe4 (diff)
downloadmpfr-91f1b7742c6d4c814311c0f85362067ed1818416.tar.gz
subnormal.c: fixed the bugs when old_inex is INT_MIN or INT_MAX.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4908 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'subnormal.c')
-rw-r--r--subnormal.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/subnormal.c b/subnormal.c
index 25a5e5c2b..fbbe24326 100644
--- a/subnormal.c
+++ b/subnormal.c
@@ -77,7 +77,8 @@ mpfr_subnormalize (mpfr_ptr y, int old_inexact, mp_rnd_t rnd)
goto set_min_p1;
/* Rounding bit is 1 and sticky bit is 0.
We need to examine old inexact flag to conclude. */
- if (old_inexact * MPFR_SIGN (y) > 0)
+ if ((old_inexact > 0 && MPFR_SIGN (y) > 0) ||
+ (old_inexact < 0 && MPFR_SIGN (y) < 0))
goto set_min;
/* If inexact != 0, return 0.1*2^(emin+1).
Otherwise, rounding bit = 1, sticky bit = 0 and inexact = 0
@@ -122,14 +123,14 @@ mpfr_subnormalize (mpfr_ptr y, int old_inexact, mp_rnd_t rnd)
if (MPFR_UNLIKELY(rnd == GMP_RNDN && (inexact == MPFR_EVEN_INEX
|| inexact == -MPFR_EVEN_INEX)))
{
- /* if both roundings are in the same direction, we have to go
+ /* if both roundings are in the same direction, we have to go
back in the other direction */
- if (old_inexact * inexact > 0)
+ if (SAME_SIGN (inexact, old_inexact))
{
- if (inexact * MPFR_INT_SIGN (y) < 0)
- mpfr_nexttoinf (dest);
- else
+ if (SAME_SIGN (inexact, MPFR_INT_SIGN (y)))
mpfr_nexttozero (dest);
+ else
+ mpfr_nexttoinf (dest);
inexact = -inexact;
}
}