diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-05-03 16:39:04 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2005-05-03 16:39:04 +0000 |
commit | d38df3ccfa69cc748f374df3561396f9522ac74c (patch) | |
tree | ac51a27c0a50432ce9a2d2d701b8561648eb1816 /atan.c | |
parent | 4b9796a72869e2797b55df29a90af490125387d5 (diff) | |
download | mpfr-d38df3ccfa69cc748f374df3561396f9522ac74c.tar.gz |
Fix computing of `sup` to reflect what is decribed in algorithms.tex.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3522 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'atan.c')
-rw-r--r-- | atan.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -247,11 +247,12 @@ mpfr_atan (mpfr_ptr atan, mpfr_srcptr x, mp_rnd_t rnd_mode) MPFR_ZIV_INIT (loop, prec); for (;;) { - /* n0 = ceil(log2(realprec + 2 + 1+ln(2.4)/ln(2))) */ - mp_prec_t sup = MAX (-MPFR_GET_EXP (xp), 0) + 2; - n0 = MPFR_INT_CEIL_LOG2 (realprec + sup + 3); + /* First, if |x| < 1, we need to have more prec to be able to round (sup) + n0 = ceil(log(prec_requested + 2 + 1+ln(2.4)/ln(2))/log(2)) */ + mp_prec_t sup = MPFR_GET_EXP (xp) < 0 ? 2-MPFR_GET_EXP (xp) : 1; + n0 = MPFR_INT_CEIL_LOG2 ((realprec + sup) + 3); MPFR_ASSERTD (3*n0 > 2); - prec = realprec + 1 + sup + MPFR_INT_CEIL_LOG2 (3*n0-2); + prec = (realprec + sup) + 1 + MPFR_INT_CEIL_LOG2 (3*n0-2); /* Initialisation */ mpfr_set_prec (sk, prec); |