summaryrefslogtreecommitdiff
path: root/round.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>1999-06-22 12:18:25 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>1999-06-22 12:18:25 +0000
commit7476cdd3e2261fd4a38c2f089f785d08d5ea74d5 (patch)
treeb5dec8ffa01b300ba61b820d05f59ff84150c12b /round.c
parentd188b1cb2a729e6962b24272329c4bdfbc228365 (diff)
downloadmpfr-7476cdd3e2261fd4a38c2f089f785d08d5ea74d5.tar.gz
fixed bug in mpfr_can_round when prec or err are multiples of BITS_PER_MP_LIMB
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@127 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'round.c')
-rw-r--r--round.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/round.c b/round.c
index 488f92ffa..4ae0a895f 100644
--- a/round.c
+++ b/round.c
@@ -165,10 +165,11 @@ mpfr_can_round_raw(mp_limb_t *bp, unsigned long bn, char neg,
if (err<=prec) return 0;
neg = (neg > 0 ? 0 : 1);
- k = err/BITS_PER_MP_LIMB;
+ /* warning: if k = m*BITS_PER_MP_LIMB, consider limb m-1 and not m */
+ k = (err-1)/BITS_PER_MP_LIMB;
l = err % BITS_PER_MP_LIMB; if (l) l = BITS_PER_MP_LIMB-l;
/* the error corresponds to bit l in limb k */
- k1 = prec/BITS_PER_MP_LIMB;
+ k1 = (prec-1)/BITS_PER_MP_LIMB;
l1 = prec%BITS_PER_MP_LIMB; if (l1) l1 = BITS_PER_MP_LIMB-l1;
/* the last significant bit is bit l1 in limb k1 */