summaryrefslogtreecommitdiff
path: root/const_log2.c
diff options
context:
space:
mode:
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);
}