summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-12-13 21:18:23 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-12-13 21:18:23 +0000
commitf78933265835f632fff2d638f4cc51bf554ecd81 (patch)
tree7611b8a0fd2c6870b65f5b67f6681669248d2beb
parent07ca2d2a4a602f87c2c647e3c6aa8a4a1c2d5340 (diff)
downloadmpfr-f78933265835f632fff2d638f4cc51bf554ecd81.tar.gz
[src/sub1sp.c] fixed bug in mpfr_sub1sp2()
[tests/tsub1sp.c] added non-regression test git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11974 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/sub1sp.c1
-rw-r--r--tests/tsub1sp.c19
2 files changed, 20 insertions, 0 deletions
diff --git a/src/sub1sp.c b/src/sub1sp.c
index a2fbd8898..bc776ee1b 100644
--- a/src/sub1sp.c
+++ b/src/sub1sp.c
@@ -608,6 +608,7 @@ mpfr_sub1sp2 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode,
{
ap[1] = (a1 << 1) | (a0 >> (GMP_NUMB_BITS - 1));
a0 = (a0 << 1) | (sb >> (GMP_NUMB_BITS - 1));
+ sb <<= 1;
bx --;
}
else
diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c
index bda7efe24..5e0342fea 100644
--- a/tests/tsub1sp.c
+++ b/tests/tsub1sp.c
@@ -218,6 +218,24 @@ compare_sub_sub1sp (void)
}
}
+static void
+bug20171213 (void)
+{
+ mpfr_t a, b, c;
+
+ mpfr_init2 (a, 127);
+ mpfr_init2 (b, 127);
+ mpfr_init2 (c, 127);
+ mpfr_set_str_binary (b, "0.1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E1");
+ mpfr_set_str_binary (c, "0.1000011010111101100101100110101111111001011001010000110000000000000000000000000000000000000000000000000000000000000000000000000E-74");
+ mpfr_sub (a, b, c, MPFR_RNDN);
+ mpfr_set_str_binary (b, "0.1111111111111111111111111111111111111111111111111111111111111111111111111101111001010000100110100110010100000001101001101011110E0");
+ MPFR_ASSERTN(mpfr_equal_p (a, b));
+ mpfr_clear (a);
+ mpfr_clear (b);
+ mpfr_clear (c);
+}
+
int
main (void)
{
@@ -228,6 +246,7 @@ main (void)
compare_sub_sub1sp ();
test20170208 ();
bug20170109 ();
+ bug20171213 ();
check_special ();
for (p = MPFR_PREC_MIN ; p < 200 ; p++)
{