From f78933265835f632fff2d638f4cc51bf554ecd81 Mon Sep 17 00:00:00 2001 From: zimmerma Date: Wed, 13 Dec 2017 21:18:23 +0000 Subject: [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 --- src/sub1sp.c | 1 + tests/tsub1sp.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) 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++) { -- cgit v1.2.1