diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-09-24 11:43:47 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-09-24 11:43:47 +0000 |
commit | 12651e7593d96f965a82ae5ce1e547731cdc565e (patch) | |
tree | 8c62d73953bd94b7bd1e110c6bef27fc4734d3df | |
parent | 293ee1f1ce17cd866063bd139070e235c981961d (diff) | |
download | mpfr-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.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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); |