summaryrefslogtreecommitdiff
path: root/rint.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 /rint.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 'rint.c')
-rw-r--r--rint.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/rint.c b/rint.c
index 89ebc66fd..aef7eb3ca 100644
--- a/rint.c
+++ b/rint.c
@@ -1,6 +1,6 @@
/* mpfr_rint -- Round to an integer.
-Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -54,7 +54,7 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
}
sign = MPFR_SIGN(u);
- exp = MPFR_EXP(u);
+ exp = MPFR_GET_EXP (u);
/* Single out the case where |u| < 1. */
if (exp <= 0) /* 0 < |u| < 1 */
@@ -70,7 +70,7 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
rm = (MPFR_PREC(r) - 1) / BITS_PER_MP_LIMB;
rp[rm] = MPFR_LIMB_HIGHBIT;
MPN_ZERO(rp, rm);
- MPFR_EXP(r) = 1; /* |r| = 1 */
+ MPFR_SET_EXP (r, 1); /* |r| = 1 */
MPFR_RET(sign > 0 ? 2 : -2);
}
else
@@ -100,7 +100,7 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
rn = MPFR_ESIZE(r);
sh = (mp_prec_t) rn * BITS_PER_MP_LIMB - MPFR_PREC(r);
- MPFR_EXP(r) = exp;
+ MPFR_SET_EXP (r, exp);
if ((exp - 1) / BITS_PER_MP_LIMB >= un)
{
@@ -217,7 +217,7 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
uflags : -uflags;
else
{
- MPFR_EXP(r)++;
+ MPFR_SET_EXP(r, MPFR_GET_EXP (r) + 1);
rp[rn-1] = MPFR_LIMB_HIGHBIT;
}
}