summaryrefslogtreecommitdiff
path: root/div.c
diff options
context:
space:
mode:
authorhanrot <hanrot@280ebfd0-de03-0410-8827-d642c229c3f4>2000-06-19 10:15:32 +0000
committerhanrot <hanrot@280ebfd0-de03-0410-8827-d642c229c3f4>2000-06-19 10:15:32 +0000
commitc2af0b84d1be8500c4546b177fbea407a7fd7c68 (patch)
tree587fe9def1eebc51f9a8f1d354f8f19a5dfcc91e /div.c
parent4ef237bf9ce2e0a0fcb4be574e7ee5c1d62dfa44 (diff)
downloadmpfr-c2af0b84d1be8500c4546b177fbea407a7fd7c68.tar.gz
Patch for 1 << (BITS_PER_MP_LIMB - x) when x is 0 (produces inexact results
on PPCs). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@635 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'div.c')
-rw-r--r--div.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/div.c b/div.c
index 0f653607b..7d8cee8cf 100644
--- a/div.c
+++ b/div.c
@@ -48,7 +48,7 @@ mpfr_div (r, u, v, rnd_mode)
mp_size_t prec, err;
mp_limb_t q_limb;
mp_exp_t rexp;
- long k, mult, vn;
+ long k, mult, vn, t;
unsigned long cc = 0, rw, nw;
char can_round = 0;
TMP_DECL (marker);
@@ -216,9 +216,18 @@ mpfr_div (r, u, v, rnd_mode)
k = rsize - 1;
while (k >= 0) { if (tp[k]) break; k--; }
if (k >= 0)
- cc = mpn_add_1(rp, rp, rrsize, (mp_limb_t)1 << (BITS_PER_MP_LIMB -
- (PREC(r) &
- (BITS_PER_MP_LIMB - 1))));
+ {
+ t = PREC(r) & (BITS_PER_MP_LIMB - 1);
+ if (t)
+ {
+ cc = mpn_add_1(rp, rp, rrsize,
+ (mp_limb_t)1 << (BITS_PER_MP_LIMB - t));
+ }
+ else
+ {
+ cc = mpn_add_1(rp, rp, rrsize, 1);
+ }
+ }
else
if (rnd_mode == GMP_RNDN) /* even rounding */
{