summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/tfrac.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/tests/tfrac.c b/tests/tfrac.c
index d81266930..6adf993c0 100644
--- a/tests/tfrac.c
+++ b/tests/tfrac.c
@@ -175,28 +175,51 @@ special (void)
static void
bug20090918 (void)
{
- mpfr_t x, y;
+ mpfr_t x, y, z;
mp_limb_t y0;
- int inex;
+ int inexy, inexz;
+ int r;
mpfr_init2 (x, 32);
mpfr_init2 (y, 13);
mpfr_set_str (x, "61680.352935791015625", 10, MPFR_RNDN);
- inex = mpfr_frac (y, x, MPFR_RNDZ);
- y0 = MPFR_MANT(y)[0];
- while ((y0 >> 1) << 1 == y0)
- y0 >>= 1;
- if (y0 > 0x2000)
- {
- printf ("Error in bug20090918 (significand has more than 13 bits).\n");
- exit (1);
- }
- if (inex >= 0)
+
+ RND_LOOP(r)
{
- printf ("Incorrect ternary value in bug20090918, expected negative,"
- " got %d.\n", inex);
- exit (1);
+ inexy = mpfr_frac (y, x, (mpfr_rnd_t) r);
+ y0 = MPFR_MANT(y)[0];
+ while ((y0 >> 1) << 1 == y0)
+ y0 >>= 1;
+ if (y0 > 0x2000)
+ {
+ printf ("Error in bug20090918 (significand has more than 13 bits),"
+ " %s.\n", mpfr_print_rnd_mode ((mpfr_rnd_t) r));
+ exit (1);
+ }
+ mpfr_init2 (z, 32);
+ inexz = mpfr_frac (z, x, MPFR_RNDN);
+ MPFR_ASSERTN (inexz == 0); /* exact */
+ inexz = mpfr_prec_round (z, 13, (mpfr_rnd_t) r);
+ if (mpfr_cmp0 (y, z) != 0)
+ {
+ printf ("Error in bug20090918, %s.\n",
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r));
+ printf ("Expected ");
+ mpfr_dump (z);
+ printf ("Got ");
+ mpfr_dump (y);
+ exit (1);
+ }
+ if (! SAME_SIGN (inexy, inexz))
+ {
+ printf ("Incorrect ternary value in bug20090918, %s.\n",
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r));
+ printf ("Expected %d, got %d.\n", inexz, inexy);
+ exit (1);
+ }
+ mpfr_clear (z);
}
+
mpfr_clear (x);
mpfr_clear (y);
}