summaryrefslogtreecommitdiff
path: root/src/rndna.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2012-07-03 15:34:39 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2012-07-03 15:34:39 +0000
commitbaf5bdaaa383670dfc5386d03b6fd334d9fe7f96 (patch)
tree20581068c0bf8bd6877fb3d5631d47555f77d225 /src/rndna.c
parent729087a03909f6d8eb8f8755005525bd038ba5f6 (diff)
downloadmpfr-baf5bdaaa383670dfc5386d03b6fd334d9fe7f96.tar.gz
[rndna.c] special treatment for the case 2^(emin-2)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8312 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/rndna.c')
-rw-r--r--src/rndna.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/rndna.c b/src/rndna.c
index 872282a99..57cadf0d3 100644
--- a/src/rndna.c
+++ b/src/rndna.c
@@ -69,5 +69,13 @@ mpfr_round_nearest_away (mpfr_t rop, mpfr_srcptr op,
mpfr_clear (tmp);
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
MPFR_SAVE_EXPO_FREE (expo);
+
+ /* special treatment for the case rop = +/- 2^(emin-2), which should be
+ rounded to +/- 2^(emin-1). We do as if it was rounded to zero, thus the
+ mpfr_check_range() call will round it to +/- 2^(emin-1). */
+ if (inex == 0 && mpfr_cmp_si_2exp (rop, (mpfr_sgn (rop) > 0) ? 1 : -1,
+ __gmpfr_emin - 2) == 0)
+ inex = -mpfr_sgn (rop);
+
return mpfr_check_range (rop, inex, MPFR_RNDN);
}