diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-02-18 13:01:46 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-02-18 13:01:46 +0000 |
commit | 4a28213bb0d80e0f03018e158841da052dc81288 (patch) | |
tree | ab0907b28e24384a8cd887b91ef3fac5c64363fc | |
parent | 3024b91c205b9acaa83824ace5623db53861b5dd (diff) | |
download | mpfr-4a28213bb0d80e0f03018e158841da052dc81288.tar.gz |
[src/sum.c] Correction. Set the exponent.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/new-sum@9285 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/sum.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -492,14 +492,17 @@ sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd, /* Let's copy/shift the bits [max(u,minexp),e) to the most significant part of the destination, and zero - the least significant part. Then take the absolute - value, and do an initial rounding. + the least significant part (there can be one only if + u < minexp). The trailing bits of the destination may + contain garbage at this point. Then, at the same time, + take the absolute value and do an initial rounding, + zeroing the trailing bits at this point. TODO: This may be improved by merging some operations is particular case. The average speed-up may not be significant, though. To be tested... */ sn = MPFR_PREC2LIMBS (sq); sd = (mpfr_prec_t) sn * GMP_NUMB_BITS - sq; - sh = (mpfr_uexp_t) e % GMP_NUMB_BITS; + sh = cancel % GMP_NUMB_BITS; if (MPFR_LIKELY (u > minexp)) { mpfr_prec_t tq; @@ -521,7 +524,11 @@ sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd, sump[0] |= wp[wi] >> (GMP_NUMB_BITS - sh); } else - MPN_COPY (sump, wp + wi, sn); + { + MPFR_ASSERTD ((mpfr_prec_t) (ws - (wi + sn)) * GMP_NUMB_BITS + == cancel); + MPN_COPY (sump, wp + wi, sn); + } /* Determine the rounding bit, which is represented. */ td = tq % GMP_NUMB_BITS; @@ -864,6 +871,7 @@ sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd, } /* Step 8 block */ + MPFR_SET_EXP (sum, e); break; } /* Steps 7 & 8 block */ } /* main loop */ |