summaryrefslogtreecommitdiff
path: root/const_log2.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-05 07:49:22 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-05-05 07:49:22 +0000
commita98d42d42e40b828d5fe1e2ea603e25e676f31cc (patch)
tree6943aa67cd45e4da9186eaf7289f6ffe793ab7ef /const_log2.c
parentc1e8d70fa718233a127753dfe3220ceb547a53df (diff)
downloadmpfr-a98d42d42e40b828d5fe1e2ea603e25e676f31cc.tar.gz
Fix a critical bug in case of overflow.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2896 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'const_log2.c')
-rw-r--r--const_log2.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/const_log2.c b/const_log2.c
index e5e6c6137..a6e4d7564 100644
--- a/const_log2.c
+++ b/const_log2.c
@@ -130,6 +130,7 @@ int
mpz_t s, t, u;
int inexact;
+ mpfr_save_emin_emax ();
precx = MPFR_PREC(x);
/* need to recompute */
@@ -153,7 +154,7 @@ int
mpz_add (s, s, u);
}
- inexact = mpfr_set_z (x, s, rnd_mode);
+ inexact = mpfr_set_z (x, s, rnd_mode); /* Can overflow => save_emin */
MPFR_SET_EXP (x, MPFR_GET_EXP (x) - N);
mpz_clear (s);
mpz_clear (t);
@@ -162,5 +163,7 @@ int
else /* use binary splitting method */
inexact = mpfr_const_aux_log2 (x, rnd_mode);
- return inexact;
+ mpfr_restore_emin_emax ();
+
+ return mpfr_check_range (x, inexact, rnd_mode);
}