diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2021-02-08 07:15:25 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2021-02-08 07:15:25 +0000 |
commit | 5f1a77e3de3e09714004b7a13aa2f46da756bad4 (patch) | |
tree | 293c8fbda04cb9f61a30c70de19577ccc6d9fb4b /src/digamma.c | |
parent | 63b642004829d5f8d8a6a372d1a7ca45eb1fbdbd (diff) | |
download | mpfr-5f1a77e3de3e09714004b7a13aa2f46da756bad4.tar.gz |
[src/digamma.c] fixed bug in mpfr_digamma_positive when t-u is zero
[tests/tdigamma.c] added corresponding non-regression test
git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14399 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/digamma.c')
-rw-r--r-- | src/digamma.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/digamma.c b/src/digamma.c index 6dba748e6..119c7430f 100644 --- a/src/digamma.c +++ b/src/digamma.c @@ -296,21 +296,24 @@ mpfr_digamma_positive (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) errt = mpfr_digamma_approx (t, x_plus_j); expt = MPFR_GET_EXP (t); mpfr_sub (t, t, u, MPFR_RNDN); - if (MPFR_GET_EXP (t) < expt) - errt += expt - MPFR_EXP(t); - /* Warning: if u is zero (which happens when x_plus_j >= min at the - beginning of the while loop above), EXP(u) is not defined. - In this case we have no error from u. */ - if (MPFR_NOTZERO(u) && MPFR_GET_EXP (t) < MPFR_GET_EXP (u)) - erru += MPFR_EXP(u) - MPFR_EXP(t); - if (errt > erru) - errt = errt + 1; - else if (errt == erru) - errt = errt + 2; - else - errt = erru + 1; - if (MPFR_CAN_ROUND (t, p - errt, MPFR_PREC(y), rnd_mode)) - break; + if (!MPFR_IS_ZERO(t)) + { + if (MPFR_GET_EXP (t) < expt) + errt += expt - MPFR_EXP(t); + /* Warning: if u is zero (which happens when x_plus_j >= min at the + beginning of the while loop above), EXP(u) is not defined. + In this case we have no error from u. */ + if (MPFR_NOTZERO(u) && MPFR_GET_EXP (t) < MPFR_GET_EXP (u)) + erru += MPFR_EXP(u) - MPFR_EXP(t); + if (errt > erru) + errt = errt + 1; + else if (errt == erru) + errt = errt + 2; + else + errt = erru + 1; + if (MPFR_CAN_ROUND (t, p - errt, MPFR_PREC(y), rnd_mode)) + break; + } MPFR_ZIV_NEXT (loop, p); mpfr_set_prec (t, p); mpfr_set_prec (u, p); |