summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exp.c3
-rw-r--r--tests/texp.c16
2 files changed, 17 insertions, 2 deletions
diff --git a/exp.c b/exp.c
index 56fbb9ce9..8ed1202f7 100644
--- a/exp.c
+++ b/exp.c
@@ -83,7 +83,8 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
int signx = MPFR_SIGN(x);
MPFR_SET_POS(y);
- if (MPFR_IS_NEG_SIGN(signx) && (rnd_mode == GMP_RNDD))
+ if (MPFR_IS_NEG_SIGN(signx) && (rnd_mode == GMP_RNDD ||
+ rnd_mode == GMP_RNDZ))
{
mpfr_setmax (y, 0); /* y = 1 - epsilon */
return -1;
diff --git a/tests/texp.c b/tests/texp.c
index 44f84d813..8127fb597 100644
--- a/tests/texp.c
+++ b/tests/texp.c
@@ -250,12 +250,16 @@ check_special ()
if (mpfr_cmp_ui_2exp (y, 3, -2))
{
printf ("Error for exp(-1/16), prec=2, RNDD\n");
+ printf ("expected 0.11, got ");
+ mpfr_dump (y);
exit (1);
}
mpfr_exp (y, x, GMP_RNDZ);
- if (mpfr_cmp_ui (y, 1))
+ if (mpfr_cmp_ui_2exp (y, 3, -2))
{
printf ("Error for exp(-1/16), prec=2, RNDZ\n");
+ printf ("expected 0.11, got ");
+ mpfr_dump (y);
exit (1);
}
mpfr_set_str_binary (x, "0.1E-3");
@@ -361,6 +365,16 @@ check_inexact (void)
mpfr_out_str (stdout, 16, 0, x, GMP_RNDN); putchar ('\n');
}
+ /* bug found by Guillaume Melquiond, 13 Sep 2005 */
+ mpfr_set_prec (x, 53);
+ mpfr_set_str_binary (x, "-1E-400");
+ mpfr_exp (x, x, GMP_RNDZ);
+ if (mpfr_cmp_ui (x, 1) == 0)
+ {
+ printf ("Error for exp(-2^(-400))\n");
+ exit (1);
+ }
+
mpfr_clear (x);
mpfr_clear (y);
}