summaryrefslogtreecommitdiff
path: root/set_si.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-05-22 21:39:40 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-05-22 21:39:40 +0000
commit44b4dd94bb98c8d9e7850ae401232bd1b2ea3028 (patch)
tree9670f0ef8017d42ad2a2062dc08c63c022e450c8 /set_si.c
parent2f3cb289a102043a22bd32c5950db37199fb3fd2 (diff)
downloadmpfr-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 'set_si.c')
-rw-r--r--set_si.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/set_si.c b/set_si.c
index af8b4f83f..4303a948f 100644
--- a/set_si.c
+++ b/set_si.c
@@ -1,6 +1,6 @@
/* mpfr_set_si -- set a MPFR number from a machine signed integer
-Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation.
This file is part of the MPFR Library.
@@ -54,7 +54,8 @@ mpfr_set_si (mpfr_ptr x, long i, mp_rnd_t rnd_mode)
if ((i < 0) ^ (MPFR_SIGN(x) < 0))
MPFR_CHANGE_SIGN(x);
- MPFR_EXP(x) = nbits = BITS_PER_MP_LIMB - cnt;
+ nbits = BITS_PER_MP_LIMB - cnt;
+ MPFR_SET_EXP (x, nbits);
inex = mpfr_check_range(x, 0, rnd_mode);
if (inex)
return inex; /* underflow or overflow */
@@ -68,12 +69,12 @@ mpfr_set_si (mpfr_ptr x, long i, mp_rnd_t rnd_mode)
rnd_mode, &inex);
if (carry)
{
- mp_exp_t exp = MPFR_EXP(x);
+ mp_exp_t exp = MPFR_GET_EXP (x);
if (exp == __gmpfr_emax)
return mpfr_set_overflow(x, rnd_mode, (i < 0 ? -1 : 1));
- MPFR_EXP(x)++;
+ MPFR_SET_EXP (x, exp + 1);
xp[xn] = MPFR_LIMB_HIGHBIT;
}
}