From afba0f707ee32f09886c762054a0e676c8ad5b3f Mon Sep 17 00:00:00 2001 From: zimmerma Date: Wed, 20 Dec 2017 10:48:26 +0000 Subject: [src/lngamma.c] fixed bug found in previous commit git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12029 280ebfd0-de03-0410-8827-d642c229c3f4 --- src/lngamma.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lngamma.c') diff --git a/src/lngamma.c b/src/lngamma.c index 147ef6bfc..c1ce77de9 100644 --- a/src/lngamma.c +++ b/src/lngamma.c @@ -397,11 +397,15 @@ GAMMA_FUNC (mpfr_ptr y, mpfr_srcptr z0, mpfr_rnd_t rnd) } else { - err_s += 1 - MPFR_GET_EXP(v); + /* if v = 0 here, it was 1 before the call to mpfr_log, + thus the error on v was zero */ + if (!MPFR_IS_ZERO(v)) + err_s += 1 - MPFR_GET_EXP(v); err_s = (err_s >= 0) ? err_s + 1 : 0; /* the error on v is bounded by 2^err_s ulps */ err_u += MPFR_GET_EXP(u); /* absolute error on u */ - err_s += MPFR_GET_EXP(v); /* absolute error on v */ + if (!MPFR_IS_ZERO(v)) /* same as above */ + err_s += MPFR_GET_EXP(v); /* absolute error on v */ mpfr_sub (s, v, u, MPFR_RNDN); /* the total error on s is bounded by ulp(s)/2 + 2^(err_u-w) + 2^(err_s-w) <= ulp(s)/2 + 2^(max(err_u,err_s)+1-w) */ -- cgit v1.2.1