From 44b4dd94bb98c8d9e7850ae401232bd1b2ea3028 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 22 May 2003 21:39:40 +0000 Subject: 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 --- set_si.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'set_si.c') 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; } } -- cgit v1.2.1