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 /set_ui.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 'set_ui.c')
-rw-r--r-- | set_ui.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -40,7 +40,7 @@ mpfr_set_ui (mpfr_ptr x, unsigned long i, mp_rnd_t rnd_mode) mp_limb_t *xp; xn = (MPFR_PREC(x)-1)/BITS_PER_MP_LIMB; - MPFR_ASSERTN(i == (mp_limb_t) i); + MPFR_ASSERTD(i == (mp_limb_t) i); count_leading_zeros(cnt, (mp_limb_t) i); xp = MPFR_MANT(x); @@ -55,15 +55,15 @@ mpfr_set_ui (mpfr_ptr x, unsigned long i, mp_rnd_t rnd_mode) return inex; /* underflow or overflow */ /* round if MPFR_PREC(x) smaller than length of i */ - if (MPFR_PREC(x) < nbits) + if (MPFR_UNLIKELY( MPFR_PREC(x) < nbits) ) { int carry; carry = mpfr_round_raw(xp+xn, xp+xn, nbits, 0, MPFR_PREC(x), rnd_mode, &inex); - if (carry) + if (MPFR_UNLIKELY(carry)) { /* nbits is the current exponent */ - if (nbits == __gmpfr_emax) + if (MPFR_UNLIKELY(nbits == __gmpfr_emax)) return mpfr_set_overflow(x, rnd_mode, 1); MPFR_SET_EXP (x, nbits + 1); |