diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-02-25 14:35:58 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-02-25 14:35:58 +0000 |
commit | 77c2d5c0b6dc40fcf1ec0b1ed174855477c7aec0 (patch) | |
tree | 8bb7ac655bda8331e98da67a1a7c07a58c14cb0e | |
parent | 75d96d6aa1aa962dc60783ac5f61c7a34264a0a6 (diff) | |
download | mpfr-77c2d5c0b6dc40fcf1ec0b1ed174855477c7aec0.tar.gz |
[src/sum.c] Bug fix: when determining the sticky bit, the search was
starting at the rounding bit instead of the bit following it.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/new-sum@9321 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/sum.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -591,16 +591,17 @@ sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd, (if the rounding bit is 0) or to possibly "correct" rbit (round to nearest, halfway case rounded downward) from which the rounding direction will be determined. */ + MPFR_LOG_MSG (("[Step 7] Determine the sticky bit...\n", 0)); - inex = td >= 1 ? (wp[wi] & MPFR_LIMB_MASK (td)) != 0 : 0; + inex = td >= 2 ? (wp[wi] & MPFR_LIMB_MASK (td - 1)) != 0 : 0; - if (inex == 0) + if (!inex) { mp_size_t wj = wi; - while (inex == 0 && wj > 0) + while (!inex && wj > 0) inex = wp[--wj] != 0; - if (inex == 0 && rbit != 0) + if (!inex && rbit != 0) { /* sticky bit = 0, rounding bit = 1, i.e. halfway case, which will be @@ -733,8 +734,8 @@ sum_aux (mpfr_ptr sum, mpfr_ptr *const x, unsigned long n, mpfr_rnd_t rnd, /* Here, if the final sum is known to be exact, inex = 0, otherwise inex = 1. */ - /* Determine carry for the initial rounding. Note that in - case of exact value (inex == 0), carry is set to 0. */ + /* Determine carry for the initial rounding. Note that in case of + value known to be exact (i.e. inex = 0), carry is set to 0. */ switch (rnd) { case MPFR_RNDD: |