summaryrefslogtreecommitdiff
path: root/tests/tpow.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-11-03 01:59:23 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-11-03 01:59:23 +0000
commit61e1ece31320999fa817e0ee9134f56e7fca2620 (patch)
tree8da5a478dde5030cb1fe3ef44a248c6638df9b16 /tests/tpow.c
parent0b46996affa6bf2199a92775e3b1fe058c8c86f4 (diff)
downloadmpfr-61e1ece31320999fa817e0ee9134f56e7fca2620.tar.gz
tpow.c: added testcase for new bug found by Kevin P. Rauch. The problem
occurs on x^y with x negative and y an integer whose exponent is > 256 (so that mpfr_pow_z isn't used, and the generic code is used instead and fails because x is negative). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4938 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tpow.c')
-rw-r--r--tests/tpow.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/tpow.c b/tests/tpow.c
index 54b724d34..dfb9e3882 100644
--- a/tests/tpow.c
+++ b/tests/tpow.c
@@ -1034,6 +1034,33 @@ mpfr_pow275 (mpfr_t y, mpfr_t x, mp_rnd_t r)
return inex;
}
+/* Bug found by Kevin P. Rauch */
+static void
+bug20071103 (void)
+{
+ mpfr_t x, y, z;
+ mp_exp_t emin, emax;
+
+ emin = mpfr_get_emin ();
+ emax = mpfr_get_emax ();
+ mpfr_set_emin (-1000000);
+ mpfr_set_emax ( 1000000);
+
+ mpfr_inits2 (64, x, y, z, (void *) 0);
+ mpfr_set_si_2exp (x, -3, -1, GMP_RNDN); /* x = -1.5 */
+ mpfr_set_str (y, "-0.ffffffffffffffff", 16, GMP_RNDN);
+ mpfr_set_exp (y, mpfr_get_emax ());
+ mpfr_clear_flags ();
+ mpfr_pow (z, x, y, GMP_RNDN);
+ mpfr_dump (z);
+ MPFR_ASSERTN (mpfr_zero_p (z) && MPFR_SIGN (z) > 0 &&
+ __gmpfr_flags == (MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT));
+ mpfr_clears (x, y, z, (void *) 0);
+
+ set_emin (emin);
+ set_emax (emax);
+}
+
int
main (void)
{
@@ -1055,6 +1082,7 @@ main (void)
overflows2 ();
overflows3 ();
x_near_one ();
+ bug20071103 ();
test_generic (2, 100, 100);
test_generic_ui (2, 100, 100);