summaryrefslogtreecommitdiff
path: root/tests/tmul_2exp.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tmul_2exp.c')
-rw-r--r--tests/tmul_2exp.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/tests/tmul_2exp.c b/tests/tmul_2exp.c
index 1e4314b38..e11d5d5cf 100644
--- a/tests/tmul_2exp.c
+++ b/tests/tmul_2exp.c
@@ -239,13 +239,14 @@ large0 (void)
large (MPFR_EMAX_MAX);
}
-/* Cases where mpfr_div_2ui overflows when rounding is like away from zero. */
+/* Cases where mpfr_div_2ui and mpfr_div_2si overflow when rounding
+ is like away from zero. */
static void
div_overflow (mpfr_exp_t e)
{
mpfr_exp_t emax;
mpfr_t x, y1, y2;
- int neg, r;
+ int neg, r, si;
emax = mpfr_get_emax ();
set_emax (e);
@@ -269,25 +270,31 @@ div_overflow (mpfr_exp_t e)
flags1 = MPFR_FLAGS_INEXACT;
if (mpfr_inf_p (y1))
flags1 |= MPFR_FLAGS_OVERFLOW;
- mpfr_clear_flags ();
- inex2 = mpfr_div_2ui (y2, x, 0, (mpfr_rnd_t) r);
- flags2 = __gmpfr_flags;
- if (!(mpfr_equal_p (y1, y2) &&
- SAME_SIGN (inex1, inex2) &&
- flags1 == flags2))
+ for (si = 0; si <= 1; si++)
{
- printf ("Error in div_overflow for %s, x = ",
- mpfr_print_rnd_mode ((mpfr_rnd_t) r));
- mpfr_dump (x);
- printf ("Expected ");
- mpfr_dump (y1);
- printf (" with inex = %d, flags =", inex1);
- flags_out (flags1);
- printf ("Got ");
- mpfr_dump (y2);
- printf (" with inex = %d, flags =", inex2);
- flags_out (flags2);
- exit (1);
+ mpfr_clear_flags ();
+ inex2 = si ?
+ mpfr_div_2si (y2, x, 0, (mpfr_rnd_t) r) :
+ mpfr_div_2ui (y2, x, 0, (mpfr_rnd_t) r);
+ flags2 = __gmpfr_flags;
+ if (!(mpfr_equal_p (y1, y2) &&
+ SAME_SIGN (inex1, inex2) &&
+ flags1 == flags2))
+ {
+ printf ("Error in div_overflow for %s, mpfr_div_2%s, x = ",
+ mpfr_print_rnd_mode ((mpfr_rnd_t) r),
+ si ? "si" : "ui");
+ mpfr_dump (x);
+ printf ("Expected ");
+ mpfr_dump (y1);
+ printf (" with inex = %d, flags =", inex1);
+ flags_out (flags1);
+ printf ("Got ");
+ mpfr_dump (y2);
+ printf (" with inex = %d, flags =", inex2);
+ flags_out (flags2);
+ exit (1);
+ }
}
}
mpfr_neg (x, x, MPFR_RNDN);