diff options
-rw-r--r-- | exp.c | 4 | ||||
-rw-r--r-- | tests/texp.c | 4 |
2 files changed, 6 insertions, 2 deletions
@@ -1,6 +1,6 @@ /* mpfr_exp -- exponential of a floating-point number -Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation. Contributed by the Spaces project. This file is part of the MPFR Library. @@ -82,9 +82,9 @@ 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)) { - MPFR_SET_POS(y); mpfr_setmax (y, 0); /* y = 1 - epsilon */ return -1; } diff --git a/tests/texp.c b/tests/texp.c index 0bd81ded1..3ff9acfae 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -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) ) @@ -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"); |