diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-02-16 02:22:30 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-02-16 02:22:30 +0000 |
commit | 69354ecc455a9735149c2543201fb77c77a86047 (patch) | |
tree | 11532c3859f364eafa91d1fd5376db5c2fbbe35a /tests/tsub.c | |
parent | 7569be36ace56e9434387415be11a745fa387531 (diff) | |
download | mpfr-69354ecc455a9735149c2543201fb77c77a86047.tar.gz |
[tests/tsub.c] More tests in bug20180216.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12257 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tsub.c')
-rw-r--r-- | tests/tsub.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/tests/tsub.c b/tests/tsub.c index 97f2ef2ee..dd1a1401b 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -981,27 +981,36 @@ static void bug20180216 (void) { mpfr_t x, y, z1, z2; - int r, p, inex; + int r, p, d, inex; - for (p = 4; p <= 4 + 4 * GMP_NUMB_BITS; p++) + for (p = 3; p <= 3 + 4 * GMP_NUMB_BITS; p++) { mpfr_inits2 (p, x, y, z1, z2, (mpfr_ptr) 0); - mpfr_set_ui (x, 5, MPFR_RNDN); - mpfr_nextabove (x); - mpfr_sub_ui (y, x, 4, MPFR_RNDN); - mpfr_set_ui (z1, 4, MPFR_RNDN); - RND_LOOP (r) + for (d = 1; d <= p-2; d++) { - inex = test_sub (z2, x, y, (mpfr_rnd_t) r); - if (! mpfr_equal_p (z1, z2) || inex != 0) + inex = mpfr_set_ui_2exp (z1, 1, d, MPFR_RNDN); /* z1 = 2^d */ + MPFR_ASSERTN (inex == 0); + inex = mpfr_add_ui (x, z1, 1, MPFR_RNDN); + MPFR_ASSERTN (inex == 0); + mpfr_nextabove (x); /* x = 2^d + 1 + epsilon */ + inex = mpfr_sub (y, x, z1, MPFR_RNDN); /* y = 1 + epsilon */ + MPFR_ASSERTN (inex == 0); + inex = mpfr_add (z2, y, z1, MPFR_RNDN); + MPFR_ASSERTN (inex == 0); + MPFR_ASSERTN (mpfr_equal_p (z2, x)); /* consistency check */ + RND_LOOP (r) { - printf ("Error in bug20180216 in precision %d, %s\n", - p, mpfr_print_rnd_mode ((mpfr_rnd_t) r)); - printf ("expected "); mpfr_dump (z1); - printf (" with inex = 0\n"); - printf ("got "); mpfr_dump (z2); - printf (" with inex = %d\n", inex); - exit (1); + inex = test_sub (z2, x, y, (mpfr_rnd_t) r); + if (! mpfr_equal_p (z1, z2) || inex != 0) + { + printf ("Error in bug20180216 with p=%d, d=%d, %s\n", + p, d, mpfr_print_rnd_mode ((mpfr_rnd_t) r)); + printf ("expected "); mpfr_dump (z1); + printf (" with inex = 0\n"); + printf ("got "); mpfr_dump (z2); + printf (" with inex = %d\n", inex); + exit (1); + } } } mpfr_clears (x, y, z1, z2, (mpfr_ptr) 0); |