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 /sub_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 'sub_one_ulp.c')
-rw-r--r-- | sub_one_ulp.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sub_one_ulp.c b/sub_one_ulp.c index 361e5853e..55d80ed5f 100644 --- a/sub_one_ulp.c +++ b/sub_one_ulp.c @@ -31,12 +31,14 @@ mpfr_sub_one_ulp(mpfr_ptr x, mp_rnd_t rnd_mode) mp_size_t xn; 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(MPFR_PREC_MIN > 1); @@ -49,7 +51,7 @@ mpfr_sub_one_ulp(mpfr_ptr x, mp_rnd_t rnd_mode) mp_exp_t exp = MPFR_EXP (x); /* Note: In case of underflow and rounding to the nearest mode, x won't be changed. Beware of infinite loops! */ - if (exp == __gmpfr_emin) + if (MPFR_UNLIKELY( exp == __gmpfr_emin )) return mpfr_set_underflow(x, rnd_mode, MPFR_SIGN(x)); else { |