diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-09-04 15:29:19 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-09-04 15:29:19 +0000 |
commit | 4f56ca9b0ab8951409bcc32206e166ae141223ea (patch) | |
tree | c0decbf4b5449b5b4c4db90ce5933a7511df7459 /src/sub1sp.c | |
parent | 7969c8c192fbb0b2f00408d3f852ff2b6eec362f (diff) | |
download | mpfr-4f56ca9b0ab8951409bcc32206e166ae141223ea.tar.gz |
[tests/tsub1sp.c] added non-regression test for bug in mpfr_sub1sp2n
[src/sub1sp.c] fixed that bug
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13600 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/sub1sp.c')
-rw-r--r-- | src/sub1sp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sub1sp.c b/src/sub1sp.c index 11a5a10d3..022251917 100644 --- a/src/sub1sp.c +++ b/src/sub1sp.c @@ -894,8 +894,12 @@ mpfr_sub1sp2n (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode) | a1 | a0 | | bp[1] | bp[0] | | t | sb | */ + /* warning: we should not ignore the low bits from cp[0] + in case d > GMP_NUMB_BITS */ sb = (d == GMP_NUMB_BITS) ? cp[0] - : (cp[1] << (2*GMP_NUMB_BITS - d)) | (cp[0] >> (d - GMP_NUMB_BITS)); + : (cp[1] << (2*GMP_NUMB_BITS - d)) + | (cp[0] >> (d - GMP_NUMB_BITS)) + | ((cp[0] << (2*GMP_NUMB_BITS - d)) != 0); t = (cp[1] >> (d - GMP_NUMB_BITS)) + (sb != 0); /* Warning: t might overflow to 0 if d=GMP_NUMB_BITS, sb <> 0, and cp[1] = 111...111 */ |