diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-28 16:31:13 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-28 16:31:13 +0000 |
commit | 117edf14c822a22cdd9c25689aeadc904a1a30d1 (patch) | |
tree | e39bd61cefc24cc6cfbc5b2b956e4fb36015d111 /add_one_ulp.c | |
parent | 734c0a144b04e2cae4e67b394010e3f6e3cadecc (diff) | |
download | mpfr-117edf14c822a22cdd9c25689aeadc904a1a30d1.tar.gz |
Use of MPFR_UNLIKELY and MPFR_IS_SINGULAR for fast detection of special values (Nan, Inf or Zero).
Start to encapsulate the sign to be independant of the reprensation (Must be 1 or -1).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2525 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'add_one_ulp.c')
-rw-r--r-- | add_one_ulp.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/add_one_ulp.c b/add_one_ulp.c index 5ae30196b..2ffe731e9 100644 --- a/add_one_ulp.c +++ b/add_one_ulp.c @@ -32,11 +32,14 @@ mpfr_add_one_ulp (mpfr_ptr x, mp_rnd_t rnd_mode) int sh; mp_limb_t *xp; - if (MPFR_IS_NAN(x)) - MPFR_RET_NAN; - - if (MPFR_IS_INF(x) || MPFR_IS_ZERO(x)) - return 0; + if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(x) )) + { + if (MPFR_IS_NAN(x)) + MPFR_RET_NAN; + if (MPFR_IS_INF(x) || MPFR_IS_ZERO(x)) + return 0; + MPFR_ASSERTN(1); + } xn = 1 + (MPFR_PREC(x) - 1) / BITS_PER_MP_LIMB; sh = (mp_prec_t) xn * BITS_PER_MP_LIMB - MPFR_PREC(x); @@ -44,7 +47,7 @@ mpfr_add_one_ulp (mpfr_ptr x, mp_rnd_t rnd_mode) if (mpn_add_1 (xp, xp, xn, MP_LIMB_T_ONE << sh)) /* got 1.0000... */ { mp_exp_t exp = MPFR_EXP (x); - if (exp == __gmpfr_emax) + if (MPFR_UNLIKELY(exp == __gmpfr_emax)) return mpfr_set_overflow(x, rnd_mode, MPFR_SIGN(x)); else { |