diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-05-10 11:49:58 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-05-10 11:49:58 +0000 |
commit | 297d69f49e18b69a52a7fbfbc69e18186a0c936a (patch) | |
tree | efaec99d184d8936558fa216ed414327c4bab1f1 /round_raw_generic.c | |
parent | 46041125369a8ea5394602f91032a30acf643078 (diff) | |
download | mpfr-297d69f49e18b69a52a7fbfbc69e18186a0c936a.tar.gz |
1. Change the prototype of mpfr_can_round to use const.
2. Change the prototype of mpfr_round_raw_2 (remove first argument since it is
useless).
3. Change round_raw_generic to use preprocessor if rather than compiler
to detect if flag == 1 or 0
4. mpfr_round_raw_xxx use const attribute too.
5. Remove mpfr_round_raw_3 since it is unused by MPFR.
6. Add first prototype of MPFR_FAST_COMPUTE_IF_SMALL.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3536 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'round_raw_generic.c')
-rw-r--r-- | round_raw_generic.c | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/round_raw_generic.c b/round_raw_generic.c index 7d0cddee5..671beba94 100644 --- a/round_raw_generic.c +++ b/round_raw_generic.c @@ -1,6 +1,7 @@ /* mpfr_round_raw_generic -- Generic rounding function -Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -50,7 +51,11 @@ MA 02111-1307, USA. */ */ int -mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, +mpfr_round_raw_generic( +#if flag == 0 + mp_limb_t *yp, +#endif + const mp_limb_t *xp, mp_prec_t xprec, int neg, mp_prec_t yprec, mp_rnd_t rnd_mode #if use_inexp != 0 , int *inexp @@ -59,7 +64,10 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, { mp_size_t xsize, nw; mp_limb_t himask, lomask, sb; - int carry, rw; + int rw; +#if flag == 0 + int carry; +#endif #if use_inexp == 0 int *inexp; #endif @@ -85,11 +93,10 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, MPFR_ASSERTD(nw >= xsize); if (use_inexp) *inexp = 0; - if (!flag) - { - MPN_COPY_DECR(yp + (nw - xsize), xp, xsize); - MPN_ZERO(yp, nw - xsize); - } +#if flag == 0 + MPN_COPY_DECR(yp + (nw - xsize), xp, xsize); + MPN_ZERO(yp, nw - xsize); +#endif return 0; } @@ -135,11 +142,13 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, *inexp = 2*MPFR_EVEN_INEX*neg-MPFR_EVEN_INEX; /* ((neg!=0)^(sb!=0)) ? MPFR_EVEN_INEX : -MPFR_EVEN_INEX;*/ /* Since neg = 0 or 1 and sb=0*/ - if (flag) - return 0 /*sb != 0 && rnd_mode != GMP_RNDZ */; +#if flag == 1 + return 0 /*sb != 0 && rnd_mode != GMP_RNDZ */; +#else MPN_COPY_INCR(yp, xp + xsize - nw, nw); yp[0] &= himask; return 0; +#endif } else { @@ -157,14 +166,16 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, /* *inexp = (neg == 0) ? 1 : -1; but since neg = 0 or 1 */ *inexp = 1-2*neg; rnd_RNDN_add_one_ulp: - if (flag) - return 1; /*sb != 0 && rnd_mode != GMP_RNDZ;*/ +#if flag == 1 + return 1; /*sb != 0 && rnd_mode != GMP_RNDZ;*/ +#else carry = mpn_add_1 (yp, xp + xsize - nw, nw, rw ? MPFR_LIMB_ONE << (BITS_PER_MP_LIMB - rw) : MPFR_LIMB_ONE); yp[0] &= himask; return carry; +#endif } } /* Rounding to Zero ? */ @@ -178,11 +189,13 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, /* rnd_mode == GMP_RNDZ and neg = 0 or 1 */ /* (neg != 0) ^ (rnd_mode != GMP_RNDZ)) ? 1 : -1);*/ *inexp = MPFR_UNLIKELY(sb == 0) ? 0 : (2*neg-1); - if (flag) - return 0; /*sb != 0 && rnd_mode != GMP_RNDZ;*/ +#if flag == 1 + return 0; /*sb != 0 && rnd_mode != GMP_RNDZ;*/ +#else MPN_COPY_INCR(yp, xp + xsize - nw, nw); yp[0] &= himask; return 0; +#endif } else { @@ -195,11 +208,13 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, if (use_inexp) /* (neg != 0) ^ (rnd_mode != GMP_RNDZ)) ? 1 : -1);*/ *inexp = 0; - if (flag) - return 0; +#if flag == 1 + return 0; +#else MPN_COPY_INCR(yp, xp + xsize - nw, nw); yp[0] &= himask; return 0; +#endif } else { @@ -207,21 +222,24 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, if (use_inexp) /* (neg != 0) ^ (rnd_mode != GMP_RNDZ)) ? 1 : -1);*/ *inexp = 1-2*neg; - if (flag) - return 1; +#if flag == 1 + return 1; +#else carry = mpn_add_1(yp, xp + xsize - nw, nw, rw ? MPFR_LIMB_ONE << (BITS_PER_MP_LIMB - rw) : 1); yp[0] &= himask; return carry; +#endif } } } else { /* Roundind mode = Zero / No inexact flag */ - if (flag) - return 0 /*sb != 0 && rnd_mode != GMP_RNDZ*/; +#if flag == 1 + return 0 /*sb != 0 && rnd_mode != GMP_RNDZ*/; +#else if (MPFR_LIKELY(rw)) { nw++; @@ -232,6 +250,7 @@ mpfr_round_raw_generic(mp_limb_t *yp, mp_limb_t *xp, mp_prec_t xprec, MPN_COPY_INCR(yp, xp + xsize - nw, nw); yp[0] &= himask; return 0; +#endif } } |