diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2012-06-25 17:03:27 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2012-06-25 17:03:27 +0000 |
commit | ba1a92a3772ede772ce5831a5bd0891c100b56e7 (patch) | |
tree | 2da870190589e5eff414c372a28a1e359a5502f7 /src/gamma.c | |
parent | f5f2a7cac48255fbd20cde6039e205d1cfbdc147 (diff) | |
download | mpfr-ba1a92a3772ede772ce5831a5bd0891c100b56e7.tar.gz |
[gamma.c] simplified code for mpfr_gamma_2_minus_x_exact() (thanks to coverage
analysis by Benjamin Dadoun)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8244 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/gamma.c')
-rw-r--r-- | src/gamma.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gamma.c b/src/gamma.c index eff62e36a..e5d349682 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -38,10 +38,13 @@ mpfr_gamma_2_minus_x_exact (mpfr_srcptr x) carry can occur, or ULP(y) > 2, and we need w >= EXP(y)-1: (a) if EXP(y) <= 1, w = PREC(y) + 2 - EXP(y) (b) if EXP(y) > 1 and EXP(y)-PREC(y) <= 1, w = PREC(y) + 1 - (c) if EXP(y) > 1 and EXP(y)-PREC(y) > 1, w = EXP(y) - 1 */ + (c) if EXP(y) > 1 and EXP(y)-PREC(y) > 1, w = EXP(y) - 1. + + Note: case (c) cannot happen in practice since this would imply that + y is integer, thus x is negative integer, which has already been tested + before any call to mpfr_gamma_2_minus_x_exact(), and NaN was returned */ return (MPFR_GET_EXP(x) <= 1) ? MPFR_PREC(x) + 2 - MPFR_GET_EXP(x) - : ((MPFR_GET_EXP(x) <= MPFR_PREC(x) + 1) ? MPFR_PREC(x) + 1 - : MPFR_GET_EXP(x) - 1); + : MPFR_PREC(x) + 1; } /* return a sufficient precision such that 1-x is exact, assuming x < 1 */ |