summaryrefslogtreecommitdiff
path: root/tests/tfrac.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-09-18 12:03:38 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-09-18 12:03:38 +0000
commita5765b637269cc7ab1c7225803e2de8cd2af6ca1 (patch)
tree88bb9e1affaa7a8a03ce3c004f2d5d2d69882571 /tests/tfrac.c
parent1952d0e174ed753c1f208320711fb2f6ee59cc1d (diff)
downloadmpfr-a5765b637269cc7ab1c7225803e2de8cd2af6ca1.tar.gz
tests/tfrac.c: more tests (there are also problems in rounding away
from zero or equivalent). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6460 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tfrac.c')
-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);
}