summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-09-24 11:43:47 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-09-24 11:43:47 +0000
commit12651e7593d96f965a82ae5ce1e547731cdc565e (patch)
tree8c62d73953bd94b7bd1e110c6bef27fc4734d3df
parent293ee1f1ce17cd866063bd139070e235c981961d (diff)
downloadmpfr-12651e7593d96f965a82ae5ce1e547731cdc565e.tar.gz
forgot to check for 0
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2989 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--get_ui.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/get_ui.c b/get_ui.c
index 0b42a90a8..1d5d286d0 100644
--- a/get_ui.c
+++ b/get_ui.c
@@ -40,10 +40,16 @@ mpfr_get_ui (mpfr_srcptr f, mp_rnd_t rnd)
mpfr_init2 (x, prec);
mpfr_rint (x, f, rnd);
- /* now the result is in the most significant limb of x */
- exp = MPFR_GET_EXP (x); /* since |x| >= 1, exp >= 1 */
- n = MPFR_LIMB_SIZE(x);
- s = MPFR_MANT(x)[n - 1] >> (BITS_PER_MP_LIMB - exp);
+ /* warning: if x=0, taking its exponent is illegal */
+ if (MPFR_IS_ZERO(x))
+ s = 0;
+ else
+ {
+ /* now the result is in the most significant limb of x */
+ exp = MPFR_GET_EXP (x); /* since |x| >= 1, exp >= 1 */
+ n = MPFR_LIMB_SIZE(x);
+ s = MPFR_MANT(x)[n - 1] >> (BITS_PER_MP_LIMB - exp);
+ }
mpfr_clear (x);