summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2006-11-17 01:56:31 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2006-11-17 01:56:31 +0000
commit773064a5ed15fbf3d7e47e2b325f24b87d4c4ca1 (patch)
treec33837efb92053e8ec3dd4da64f343377bd1faea /tests
parentdb84ffff5f3fb1a396a4764a19bfc7ed86bb6c26 (diff)
downloadmpfr-773064a5ed15fbf3d7e47e2b325f24b87d4c4ca1.tar.gz
Fixed a bug in mpfr_pow_z concerning the underflow flag and added the
corresponding testcase (but the case z < 0 is still buggy concerning the flags). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4221 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tpow.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/tpow.c b/tests/tpow.c
index 4f022041b..65acc3b65 100644
--- a/tests/tpow.c
+++ b/tests/tpow.c
@@ -584,6 +584,7 @@ underflows (void)
int err = 0;
int inexact;
int i;
+ mp_exp_t emin;
mpfr_init2 (x, 64);
mpfr_init2 (y, 64);
@@ -655,6 +656,27 @@ underflows (void)
exit (1);
}
+ emin = mpfr_get_emin ();
+ mpfr_set_emin (-256);
+ mpfr_set_prec (x, 2);
+ mpfr_set_prec (y, 2);
+ mpfr_set_prec (z, 12);
+ mpfr_set_ui_2exp (x, 3, -2, GMP_RNDN);
+ mpfr_set_ui_2exp (y, 1, 38, GMP_RNDN);
+ mpfr_clear_flags ();
+ inexact = mpfr_pow (z, x, y, GMP_RNDN);
+ if (!mpfr_underflow_p () || MPFR_NOTZERO (z) || inexact >= 0)
+ {
+ printf ("Bad underflow detection for 0.75^(2^38). Obtained:\n"
+ "Underflow flag... %-3s (should be 'yes')\n"
+ "Zero result...... %-3s (should be 'yes')\n"
+ "Inexact value.... %-3d (should be negative)\n",
+ mpfr_underflow_p () ? "yes" : "no",
+ MPFR_IS_ZERO (z) ? "yes" : "no", inexact);
+ exit (1);
+ }
+ mpfr_set_emin (emin);
+
mpfr_clears (x, y, z, (void *) 0);
}