diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-05-22 21:39:40 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-05-22 21:39:40 +0000 |
commit | 44b4dd94bb98c8d9e7850ae401232bd1b2ea3028 (patch) | |
tree | 9670f0ef8017d42ad2a2062dc08c63c022e450c8 /sub1.c | |
parent | 2f3cb289a102043a22bd32c5950db37199fb3fd2 (diff) | |
download | mpfr-44b4dd94bb98c8d9e7850ae401232bd1b2ea3028.tar.gz |
Macros MPFR_EXP_INVALID (invalid exponent value) and MPFR_EXP_CHECK
added. Code update to use MPFR_GET_EXP and MPFR_SET_EXP instead of
MPFR_EXP to allow more bug detection related to special values.
Macros MPFR_SET_NAN, MPFR_SET_INF, MPFR_SET_ZERO and MPFR_INIT set
the exponent of the number to MPFR_EXP_INVALID if MPFR_EXP_CHECK
is defined. Compile with -DMPFR_EXP_CHECK and make check to see
the potential problems; currently, 40 of 76 tests fail.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2301 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub1.c')
-rw-r--r-- | sub1.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -1,6 +1,6 @@ /* mpfr_sub1 -- internal function to perform a "real" subtraction -Copyright 2001, 2002 Free Software Foundation. +Copyright 2001, 2002, 2003 Free Software Foundation. Contributed by the Spaces project, INRIA Lorraine. This file is part of the MPFR Library. @@ -74,7 +74,7 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode, if (!sub) MPFR_SET_SAME_SIGN(a, b); - diff_exp = (mp_exp_unsigned_t) MPFR_EXP(b) - MPFR_EXP(c); + diff_exp = (mp_exp_unsigned_t) MPFR_GET_EXP (b) - MPFR_GET_EXP (c); /* reserve a space to store b aligned with the result, i.e. shifted by (-cancel) % BITS_PER_MP_LIMB to the right */ @@ -393,7 +393,7 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode, mp_exp_t exp_a; cancel -= add_exp; /* still valid as unsigned long */ - exp_a = MPFR_EXP(b) - cancel; + exp_a = MPFR_GET_EXP (b) - cancel; if (exp_a < __gmpfr_emin) { TMP_FREE(marker); @@ -403,19 +403,22 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode, rnd_mode = GMP_RNDZ; return mpfr_set_underflow (a, rnd_mode, MPFR_SIGN(a)); } - MPFR_EXP(a) = exp_a; + MPFR_SET_EXP (a, exp_a); } else /* cancel = 0: MPFR_EXP(a) <- MPFR_EXP(b) + add_exp */ { /* in case cancel = 0, add_exp can still be 1, in case b is just below a power of two, c is very small, prec(a) < prec(b), and rnd=away or nearest */ - if (add_exp && MPFR_EXP(b) == __gmpfr_emax) + mp_exp_t exp_b; + + exp_b = MPFR_GET_EXP (b); + if (add_exp && exp_b == __gmpfr_emax) { TMP_FREE(marker); return mpfr_set_overflow (a, rnd_mode, MPFR_SIGN(a)); } - MPFR_EXP(a) = MPFR_EXP(b) + add_exp; + MPFR_SET_EXP (a, exp_b + add_exp); } TMP_FREE(marker); #ifdef DEBUG |