diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2000-11-28 08:25:14 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2000-11-28 08:25:14 +0000 |
commit | df4d4495a445311787bbbe377dff3a0690eedfdd (patch) | |
tree | 8b0dfcdf688cbd96b5e268718535af2172347307 /sub.c | |
parent | 36266dd10cc8b9296b133cb3cf59ca39daaee92c (diff) | |
download | mpfr-df4d4495a445311787bbbe377dff3a0690eedfdd.tar.gz |
fixed bug when imax>an
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@796 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub.c')
-rw-r--r-- | sub.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -303,12 +303,13 @@ mpfr_sub1(a, b, c, rnd_mode, diff_exp) if (MPFR_PREC(b)<=MPFR_PREC(a)+cancel) { int i, imax; overlap += 2; /* invert low limbs */ - imax = (int)an-(int)bn+cancel1; + imax = (int)an - (int)bn + cancel1; + if (imax > an) imax = an; for (i=0;i<imax;i++) ap[i] = ~ap[i]; cc = (i) ? mpn_add_1(ap, ap, i, 1) : 1; - if (cancel1<bn) mpn_sub_lshift_n(ap+i, bp, bn-cancel1, cancel2, an); + if (cancel1 < bn) mpn_sub_lshift_n(ap+i, bp, bn-cancel1, cancel2, an); /* warning: mpn_sub_1 doesn't accept a zero length */ - if (i<an) mpn_sub_1(ap+i, ap+i, an-i, ONE-cc); + if (i < an) mpn_sub_1(ap+i, ap+i, an-i, ONE-cc); } else /* MPFR_PREC(b) > MPFR_PREC(a): we have to truncate b */ mpn_sub_lshift_n(ap, bp+(bn-an-cancel1), an, cancel2, an); |