diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-02-09 09:55:51 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-02-09 09:55:51 +0000 |
commit | 06264e7571d13a12f4b6de11f41980abe8f1eb19 (patch) | |
tree | e2683ad8805741a4ad608b29d98cd1e24564293c | |
parent | c28806b7186defca48d92df82108b730df4d194c (diff) | |
download | mpfr-06264e7571d13a12f4b6de11f41980abe8f1eb19.tar.gz |
[src/eint.c] Fixed eint(-inf).
[tests/teint.c] Added a corresponding test.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10008 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/eint.c | 10 | ||||
-rw-r--r-- | tests/teint.c | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/eint.c b/src/eint.c index a32d71a49..02f1f3b39 100644 --- a/src/eint.c +++ b/src/eint.c @@ -212,16 +212,18 @@ mpfr_eint (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) { - /* exp(NaN) = exp(-Inf) = NaN */ - if (MPFR_IS_NAN (x) || (MPFR_IS_INF (x) && MPFR_IS_NEG(x))) + if (MPFR_IS_NAN (x)) { MPFR_SET_NAN (y); MPFR_RET_NAN; } - /* eint(+inf) = +inf */ else if (MPFR_IS_INF (x)) { - MPFR_SET_INF(y); + /* eint(+inf) = +inf and eint(-inf) = +0 */ + if (MPFR_IS_POS (x)) + MPFR_SET_INF(y); + else + MPFR_SET_ZERO(y); MPFR_SET_POS(y); MPFR_RET(0); } diff --git a/tests/teint.c b/tests/teint.c index aa8d513a3..4a29eec01 100644 --- a/tests/teint.c +++ b/tests/teint.c @@ -49,6 +49,14 @@ check_specials (void) exit (1); } + mpfr_set_inf (x, -1); + mpfr_eint (y, x, MPFR_RNDN); + if (! (mpfr_zero_p (y) && MPFR_IS_POS (y))) + { + printf ("Error: eint(-Inf) != +0\n"); + exit (1); + } + /* eint(+/-0) = -Inf */ mpfr_set_ui (x, 0, MPFR_RNDN); mpfr_eint (y, x, MPFR_RNDN); |