summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-26 07:42:49 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-06-26 07:42:49 +0000
commit0933df3719141a37c83a059be4608f363c8d7d74 (patch)
tree0f65cdf3f75191dd9e2f30de7476adfa1fa14158 /tests
parentfa563bc7f4e90c6a2801b70ba0e273c183cafb5c (diff)
downloadmpfr-0933df3719141a37c83a059be4608f363c8d7d74.tar.gz
[src/div_2si.c] Fixed overflow case when n = 0.
[tests/tmul_2exp.c] In the overflow test, check mpfr_div_2si too. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9596 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-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);