summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-09-13 14:53:35 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-09-13 14:53:35 +0000
commit2158e2bdb1744edd687b30342cafdb9b8c1a3d75 (patch)
tree92da2792b0b624c16a8ddc6a791684511abfb315
parent88323cd2cc1ec26f915de6c90df8c5aed52c48bf (diff)
downloadmpfr-2-1-branch.tar.gz
Fixed bug in exp(-eps) for rounding toward zero (test was also wrong).mpfr-2-1-branch
[2.1 branch] git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/mpfr-2-1-branch@3847 280ebfd0-de03-0410-8827-d642c229c3f4
-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);
}