summaryrefslogtreecommitdiff
path: root/tests/texp.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/texp.c')
-rw-r--r--tests/texp.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/texp.c b/tests/texp.c
index d1bba9a51..3ff9acfae 100644
--- a/tests/texp.c
+++ b/tests/texp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_exp.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -31,6 +31,8 @@ check3 (const char *op, mp_rnd_t rnd, const char *res)
mpfr_t x, y;
mpfr_inits2 (53, x, y, NULL);
+ /* y negative. If we forget to set the sign in mpfr_exp, we'll see it. */
+ mpfr_set_si (y, -1, GMP_RNDN);
mpfr_set_str1 (x, op);
mpfr_exp (y, x, rnd);
if (mpfr_cmp_str1 (y, res) )
@@ -142,7 +144,7 @@ compare_exp2_exp3 (int n)
mpfr_set_prec (y, prec);
mpfr_set_prec (z, prec);
mpfr_random (x);
- rnd = RND_RAND() ;
+ rnd = (mp_rnd_t) RND_RAND();
mpfr_exp_2 (y, x, rnd);
mpfr_exp_3 (z, x, rnd);
if (mpfr_cmp (y,z))
@@ -217,7 +219,7 @@ check_special ()
/* check overflow */
emax = mpfr_get_emax ();
- mpfr_set_emax (10);
+ set_emax (10);
mpfr_set_ui (x, 7, GMP_RNDN);
mpfr_exp (y, x, GMP_RNDN);
if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
@@ -225,11 +227,11 @@ check_special ()
printf ("Error for exp(7) for emax=10\n");
exit (1);
}
- mpfr_set_emax (emax);
+ set_emax (emax);
/* check underflow */
emin = mpfr_get_emin ();
- mpfr_set_emin (-10);
+ set_emin (-10);
mpfr_set_si (x, -9, GMP_RNDN);
mpfr_exp (y, x, GMP_RNDN);
if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
@@ -239,7 +241,7 @@ check_special ()
printf ("Got "); mpfr_print_binary (y); puts ("");
exit (1);
}
- mpfr_set_emin (emin);
+ set_emin (emin);
/* check case EXP(x) < -precy */
mpfr_set_prec (y, 2);
@@ -295,8 +297,8 @@ check_special ()
mpfr_exp_3 (y, x, GMP_RNDN);
/* Check some little things about overflow detection */
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_set_prec (x, 107);
mpfr_set_prec (y, 107);
mpfr_set_str_binary (x, "0.11110000000000000000000000000000000000000000000"
@@ -312,8 +314,8 @@ check_special ()
exit (1);
}
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
/* Check for overflow producing a segfault with HUGE exponent */
mpfr_set_ui (x, 3, GMP_RNDN);
@@ -385,6 +387,8 @@ main (int argc, char *argv[])
compare_exp2_exp3(500);
check_worst_cases();
check3("0.0", GMP_RNDU, "1.0");
+ check3("-1e-170", GMP_RNDU, "1.0");
+ check3("-1e-170", GMP_RNDN, "1.0");
check3("-8.88024741073346941839e-17", GMP_RNDU, "1.0");
check3("8.70772839244701057915e-01", GMP_RNDN, "2.38875626491680437269");
check3("1.0", GMP_RNDN, "2.71828182845904509080");