summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-02-25 15:17:32 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-02-25 15:17:32 +0000
commit8f1c94f45e51276da1c8e9f6a12a37c0cdee8d01 (patch)
tree236fc84428d51dcf2c31f3c7cdbd258c141e0b56
parent77c2d5c0b6dc40fcf1ec0b1ed174855477c7aec0 (diff)
downloadmpfr-8f1c94f45e51276da1c8e9f6a12a37c0cdee8d01.tar.gz
[src/sum.c] Improved the setting of sst (Step 8), using the fact
that the accumulator is 0 iff cancel = 0. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/new-sum@9322 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/sum.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/sum.c b/src/sum.c
index 612021db1..eebda25cb 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -878,25 +878,19 @@ sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd,
cancel = sum_raw (wp, ws, wq, x, n, minexp, maxexp, tp, ts,
logn, cq, 0, NULL, NULL, &minexp, &maxexp);
- if ((wp[ws-1] & MPFR_LIMB_HIGHBIT) != 0)
- sst = -1;
- else if (maxexp != MPFR_EXP_MIN)
- sst = 1;
+ if (cancel != 0)
+ sst = (wp[ws-1] & MPFR_LIMB_HIGHBIT) == 0 ? 1 : -1;
+ else if (tmd == 1)
+ sst = 0;
else
{
- do
- sst = wp[ws] != 0;
- while (sst == 0 && ws-- > 0);
- if (sst == 0 && tmd == 2)
- {
- /* For halfway cases, let's virtually eliminate them
- by setting a sst equivalent to a non-halfway case,
- which depends on the last bit of the pre-rounded
- result and the sign. */
- MPFR_ASSERTD (rnd == MPFR_RNDN);
- sst = (sump[0] & (MPFR_LIMB_ONE << sd)) ?
- (pos ? 1 : -1) : (pos ? -1 : 1);
- }
+ /* For halfway cases, let's virtually eliminate them
+ by setting a sst equivalent to a non-halfway case,
+ which depends on the last bit of the pre-rounded
+ result and the sign. */
+ MPFR_ASSERTD (rnd == MPFR_RNDN && tmd == 2);
+ sst = (sump[0] & (MPFR_LIMB_ONE << sd)) ?
+ (pos ? 1 : -1) : (pos ? -1 : 1);
}
MPFR_LOG_MSG (("[Step 8] tmd=%d rbit=%d sst=%d\n",