summaryrefslogtreecommitdiff
path: root/sub.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2000-02-02 15:52:54 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2000-02-02 15:52:54 +0000
commitfce3f4f20591a6f6ed3fca24a56915ce13d4b951 (patch)
treef01d5f577bb18b23919a502afa3e0fa97971e48b /sub.c
parentaacc3e6609803eca57916676bd0a599aeb340892 (diff)
downloadmpfr-fce3f4f20591a6f6ed3fca24a56915ce13d4b951.tar.gz
fixed mpn_rshift which could have 0 as shift argument
(caused bug in exp on Solaris found by JP Merlet) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@433 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub.c')
-rw-r--r--sub.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sub.c b/sub.c
index 363add620..570333f6f 100644
--- a/sub.c
+++ b/sub.c
@@ -254,7 +254,12 @@ mpfr_sub1(a, b, c, rnd_mode, diff_exp)
else { /* shift to the right by -overlap bits */
overlap = -overlap;
k = overlap/mp_bits_per_limb;
- cc=mpn_rshift(ap+(an-k-cn),cp,cn,overlap%mp_bits_per_limb);
+ overlap = overlap % mp_bits_per_limb;
+ if (overlap) cc = mpn_rshift(ap+(an-k-cn), cp, cn, overlap);
+ else {
+ MPN_COPY(ap+(an-k-cn), cp, cn);
+ cc = 0;
+ }
if (an>k+cn) ap[an-k-cn-1]=cc;
}
overlap=0;
@@ -272,7 +277,7 @@ mpfr_sub1(a, b, c, rnd_mode, diff_exp)
for (i=0;i<imax;i++) ap[i] = ~ap[i];
cc = (i) ? mpn_add_1(ap, ap, i, 1) : 1;
mpn_sub_lshift_n(ap+i, bp, bn-cancel1, cancel2, an);
- mpn_sub_1(ap+i, ap+i, an-i, 1-cc);
+ mpn_sub_1(ap+i, ap+i, an-i, (mp_limb_t)1-cc);
}
else /* PREC(b) > PREC(a): we have to truncate b */
mpn_sub_lshift_n(ap, bp+(bn-an-cancel1), an, cancel2, an);