diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-04-18 11:56:09 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-04-18 11:56:09 +0000 |
commit | 0efbec475e1103f8bddc6f8cff256f55c2bea277 (patch) | |
tree | cb768048a66e823353320260b385b0812abfcc87 /sub.c | |
parent | 5bf44e9c2bf2826e5b030937dd88bc94a88194e3 (diff) | |
download | mpfr-0efbec475e1103f8bddc6f8cff256f55c2bea277.tar.gz |
fixed new bug found by Nathalie Revol (case when add_one_ulp produces a carry)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1079 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub.c')
-rw-r--r-- | sub.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -523,7 +523,7 @@ mpfr_sub1 (a, b, c, rnd_mode, diff_exp) to_nearest: /* 0 <= sh < BITS_PER_MP_LIMB : number of bits of a to truncate bp[k] : last significant limb from b */ #ifdef DEBUG -mpfr_print_raw(a); putchar('\n'); + mpfr_print_raw(a); putchar('\n'); #endif if (sh) { cc = *ap & ((ONE<<sh)-1); @@ -558,12 +558,20 @@ mpfr_print_raw(a); putchar('\n'); cc = mpn_sub_1(ap, ap, an, ONE<<sh); goto end_of_sub; - add_one_ulp: /* add one unit in last place to a */ - cc = mpn_add_1(ap, ap, an, ONE<<sh); + add_one_ulp: /* add one unit in last place to a */ + if (mpn_add_1(ap, ap, an, ONE<<sh)) /* result is a power of two */ + { + ap[an-1] = ONE << (BITS_PER_MP_LIMB - 1); + MPFR_EXP(a)++; + } end_of_sub: #ifdef DEBUG -printf("b-c="); if (MPFR_SIGN(a)>0) putchar(' '); mpfr_print_raw(a); putchar('\n'); + printf ("b-c="); + if (MPFR_SIGN(a)>0) + putchar (' '); + mpfr_print_raw (a); + putchar ('\n'); #endif TMP_FREE(marker); return; |