summaryrefslogtreecommitdiff
path: root/tests/texp.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-05-11 15:24:48 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-05-11 15:24:48 +0000
commit924f9a3973526ca1beac7ce20b7c7d86e5267763 (patch)
tree15838b207e13b8f89d254c6f74844d4cdaa175b2 /tests/texp.c
parent17a548dd6cb64dd94cc7d2d3893258d4a68741e5 (diff)
downloadmpfr-924f9a3973526ca1beac7ce20b7c7d86e5267763.tar.gz
Fix bug when exp(x) is near the limit of an overflow or an
underflow (mpfr_exp_2 didn't allow an overflow/underflow in its internal loop). Add corresponding test case. exp_3 may need similar patchs. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3539 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/texp.c')
-rw-r--r--tests/texp.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/texp.c b/tests/texp.c
index 25a3f0b79..467709458 100644
--- a/tests/texp.c
+++ b/tests/texp.c
@@ -240,6 +240,45 @@ check_special ()
exit (1);
}
+ /* Check overflow. Corner case of mpfr_exp_2 */
+ mpfr_set_prec (x, 64);
+ mpfr_set_emax (MPFR_EMAX_DEFAULT);
+ mpfr_set_emin (MPFR_EMIN_DEFAULT);
+ mpfr_set_str (x,
+ "0.1011000101110010000101111111010100001100000001110001100111001101E30",
+ 2, GMP_RNDN);
+ mpfr_exp (x, x, GMP_RNDD);
+ if (mpfr_cmp_str (x,
+".1111111111111111111111111111111111111111111111111111111111111111E1073741823",
+ 2, GMP_RNDN) != 0)
+ {
+ printf ("Wrong overflow detection in mpfr_exp\n");
+ mpfr_dump (x);
+ exit (1);
+ }
+ /* Check underflow. Corner case of mpfr_exp_2 */
+ mpfr_set_str (x,
+"-0.1011000101110010000101111111011111010001110011110111100110101100E30",
+ 2, GMP_RNDN);
+ mpfr_exp (x, x, GMP_RNDN);
+ if (mpfr_cmp_str (x, "0.1E-1073741823", 2, GMP_RNDN) != 0)
+ {
+ printf ("Wrong underflow (1) detection in mpfr_exp\n");
+ mpfr_dump (x);
+ exit (1);
+ }
+ mpfr_set_str (x,
+"-0.1011001101110010000101111111011111010001110011110111100110111101E30",
+ 2, GMP_RNDN);
+ mpfr_exp (x, x, GMP_RNDN);
+ if (mpfr_cmp_ui (x, 0) != 0)
+ {
+ printf ("Wrong underflow (2) detection in mpfr_exp\n");
+ mpfr_dump (x);
+ exit (1);
+ }
+ mpfr_set_prec (x, 53);
+
/* check overflow */
emax = mpfr_get_emax ();
set_emax (10);