summaryrefslogtreecommitdiff
path: root/lngamma.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2007-07-03 19:10:33 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2007-07-03 19:10:33 +0000
commit1e1a3c32cd8d8fc0a50ea2f1efd2b4f478fd774d (patch)
treeeb874fcd4133ceddbd285c2a164a268392d0be2d /lngamma.c
parent7acfefe1884bce32d27aeb3272bc169fb066fbfa (diff)
downloadmpfr-1e1a3c32cd8d8fc0a50ea2f1efd2b4f478fd774d.tar.gz
fixed bug in tlgamma and added test (need to implement Ziv's strategy in
tiny case) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4625 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'lngamma.c')
-rw-r--r--lngamma.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lngamma.c b/lngamma.c
index bd2e54607..9d403f8bb 100644
--- a/lngamma.c
+++ b/lngamma.c
@@ -610,9 +610,12 @@ mpfr_lgamma (mpfr_ptr y, int *signp, mpfr_srcptr x, mp_rnd_t rnd)
{
mpfr_t l, h;
int ok, inex2;
-
- mpfr_init2 (l, MPFR_PREC(y) + 14);
- mpfr_init2 (h, MPFR_PREC(y) + 14);
+ mp_prec_t w = MPFR_PREC(y) + 14;
+
+ while (1)
+ {
+ mpfr_init2 (l, w);
+ mpfr_init2 (h, w);
/* we want a lower bound on -log(-x), thus an upper bound on log(-x),
thus an upper bound on -x. */
mpfr_neg (l, x, GMP_RNDU); /* upper bound on -x */
@@ -636,6 +639,8 @@ mpfr_lgamma (mpfr_ptr y, int *signp, mpfr_srcptr x, mp_rnd_t rnd)
mpfr_clear (h);
if (ok)
return inex;
+ w += MPFR_INT_CEIL_LOG2 (w) + 3;
+ }
}
}