diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-12-10 13:40:52 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-12-10 13:40:52 +0000 |
commit | bdfa92606a21aa3796d5fcc3ec6507537cb44dc8 (patch) | |
tree | d682bc42aefe824f7d482e1be03bd22ece08c762 | |
parent | 3bef3c58b770fe0b4e12a54641952fbb7fc6a72b (diff) | |
download | mpfr-bdfa92606a21aa3796d5fcc3ec6507537cb44dc8.tar.gz |
+ Add a new test in case of underflow.
+ Fix bug in case of underflow for sub1 / sub1sp (mpfr_powerof2 could be called with inalid numbers).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2571 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | powerof2.c | 5 | ||||
-rw-r--r-- | sub1sp.c | 2 | ||||
-rw-r--r-- | tests/tsub1sp.c | 4 |
3 files changed, 8 insertions, 3 deletions
diff --git a/powerof2.c b/powerof2.c index f549fdfa3..9326d5811 100644 --- a/powerof2.c +++ b/powerof2.c @@ -32,7 +32,10 @@ mpfr_powerof2_raw (mpfr_srcptr x) mp_limb_t *xp; mp_size_t xn; - MPFR_ASSERTN(MPFR_IS_PURE_FP(x)); + /* This is an internal function, and we may call it with some + wrong numbers (ie good mantissa but wrong flags or exp) + So we don't want to test if it is a pure FP. + MPFR_ASSERTN(MPFR_IS_PURE_FP(x)); */ xp = MPFR_MANT(x); xn = (MPFR_PREC(x) - 1) / BITS_PER_MP_LIMB; if (NOT_POW2(xp[xn])) @@ -209,7 +209,7 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) if (MPFR_LIKELY(sh)) ap[len] &= ~((MPFR_LIMB_ONE << sh) - MPFR_LIMB_ONE); } - /* Check expo overflow */ + /* Check expo underflow */ if (MPFR_UNLIKELY(bx < __gmpfr_emin)) { TMP_FREE(marker); diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c index 66ee6af64..0be1dd5e8 100644 --- a/tests/tsub1sp.c +++ b/tests/tsub1sp.c @@ -346,11 +346,13 @@ void check_special(void) if (inexact1 != inexact2) STD_ERROR2; + MPFR_SET_NAN(x); + MPFR_SET_NAN(x2); mpfr_set_str_binary (y, "0.1000000000000000000000000000000000000000000000000000000000000000" "E-1073741823"); mpfr_set_str_binary (z, - "0.1010000000000000000000000000000000000000000000000000000000000000" + "0.1100000000000000000000000000000000000000000000000000000000000000" "E-1073741823"); inexact1 = mpfr_sub1(x2, y, z, r); inexact2 = mpfr_sub1sp(x, y, z, r); |