summaryrefslogtreecommitdiff
path: root/tests/tdiv.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-01-26 15:23:39 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-01-26 15:23:39 +0000
commit17c4d1ace7e5395e65124da44a13bbce858573bc (patch)
tree5c8c7b8065c514eb96ff959e2a9b51879a52123a /tests/tdiv.c
parentb8d689853d47f727d8b919869dcfd427e4ecbe6e (diff)
downloadmpfr-17c4d1ace7e5395e65124da44a13bbce858573bc.tar.gz
[tests/tdiv.c] Added test case for a mpfr_div bug of MPFR 4.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12128 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tdiv.c')
-rw-r--r--tests/tdiv.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/tdiv.c b/tests/tdiv.c
index 2ef925fda..02ffbec33 100644
--- a/tests/tdiv.c
+++ b/tests/tdiv.c
@@ -1519,11 +1519,70 @@ bug20171218 (void)
mpfr_clear (c);
}
+/* Extended test based on a bug found with flint-arb test suite with a
+ 32-bit ABI: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=888459
+ A failure may occur in r12126 with pb=GMP_NUMB_BITS and MPFR_RNDN.
+*/
+static void
+bug20180126 (void)
+{
+ mpfr_t a, b1, b2, c1, c2;
+ int pa, i, j, pc, r, inex1, inex2;
+
+ for (pa = 100; pa < 800; pa += 11)
+ for (i = 1; i <= 4; i++)
+ for (j = -2; j <= 2; j++)
+ {
+ int pb = GMP_NUMB_BITS * i + j;
+
+ if (pb > pa)
+ continue;
+
+ mpfr_inits2 (pa, a, b1, (mpfr_ptr) 0);
+ mpfr_inits2 (pb, b2, (mpfr_ptr) 0);
+
+ mpfr_set_ui (a, 1, MPFR_RNDN);
+ mpfr_nextbelow (a);
+ mpfr_set_ui (b2, 1, MPFR_RNDN);
+ mpfr_nextbelow (b2);
+ inex1 = mpfr_set (b1, b2, MPFR_RNDN);
+ MPFR_ASSERTN (inex1 == 0);
+
+ for (pc = 32; pc <= 320; pc += 32)
+ {
+ mpfr_inits2 (pc, c1, c2, (mpfr_ptr) 0);
+
+ RND_LOOP_NO_RNDF (r)
+ {
+ inex1 = mpfr_div (c1, a, b1, (mpfr_rnd_t) r);
+ inex2 = mpfr_div (c2, a, b2, (mpfr_rnd_t) r);
+
+ if (! mpfr_equal_p (c1, c2) || ! SAME_SIGN (inex1, inex2))
+ {
+ printf ("Error in bug20180126 for "
+ "pa=%d pb=%d pc=%d %s\n", pa, pb, pc,
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r));
+ printf ("inex1 = %d, c1 = ", inex1);
+ mpfr_dump (c1);
+ printf ("inex2 = %d, c2 = ", inex2);
+ mpfr_dump (c2);
+ exit (1);
+ }
+ }
+
+ mpfr_clears (c1, c2, (mpfr_ptr) 0);
+ }
+
+ mpfr_clears (a, b1, b2, (mpfr_ptr) 0);
+ }
+}
+
int
main (int argc, char *argv[])
{
tests_start_mpfr ();
+ bug20180126 ();
bug20171218 ();
testall_rndf (9);
test_20170105 ();