diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-01 15:06:25 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-01 15:06:25 +0000 |
commit | b8e75892c38435c76aadc66aceaac8a17a19b72f (patch) | |
tree | fbf15a6c2928fccf74f695a7514959f407216ea2 /const_log2.c | |
parent | 6937af5229b3b091e109b8c7cb7b31aba3da1177 (diff) | |
download | mpfr-b8e75892c38435c76aadc66aceaac8a17a19b72f.tar.gz |
Corrections in the MPFR manual (PZ & VL). Functions mpfr_const_pi,
mpfr_const_log2 and mpfr_zeta now return a ternary value. Updated
TODO file.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2463 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'const_log2.c')
-rw-r--r-- | const_log2.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/const_log2.c b/const_log2.c index 1fdd0cf2d..61155b003 100644 --- a/const_log2.c +++ b/const_log2.c @@ -43,7 +43,7 @@ static int mpfr_const_aux_log2 _PROTO ((mpfr_ptr, mp_rnd_t)); #define NO_FACTORIAL #undef R_IS_RATIONAL #define GENERIC mpfr_aux_log2 -#include "generic.c" +#include "generic.c" #undef A #undef A1 #undef A2 @@ -57,7 +57,7 @@ static int mpfr_const_aux_log2 (mpfr_ptr mylog, mp_rnd_t rnd_mode) { mp_prec_t prec; - mpfr_t tmp1, tmp2, result,tmp3; + mpfr_t tmp1, tmp2, result,tmp3; mpz_t cst; int good = 0; int logn; @@ -111,7 +111,7 @@ mpfr_const_aux_log2 (mpfr_ptr mylog, mp_rnd_t rnd_mode) target machine should be determined by tuneup. */ #define LOG2_THRESHOLD 25000 -/* set x to log(2) rounded to precision MPFR_PREC(x) with direction rnd_mode +/* set x to log(2) rounded to precision MPFR_PREC(x) with direction rnd_mode use formula log(2) = sum(1/k/2^k, k=1..infinity) @@ -124,14 +124,14 @@ mpfr_const_aux_log2 (mpfr_ptr mylog, mp_rnd_t rnd_mode) Then 2^N*log(2)-S'(N) <= N-1+2/N <= N for N>=2. */ -void +int mpfr_const_log2 (mpfr_ptr x, mp_rnd_t rnd_mode) { mp_prec_t N, k, precx; mpz_t s, t, u; precx = MPFR_PREC(x); - MPFR_CLEAR_FLAGS(x); + MPFR_CLEAR_FLAGS(x); /* has stored value enough precision ? */ if (precx <= __gmpfr_const_log2_prec) @@ -140,11 +140,10 @@ mpfr_const_log2 (mpfr_ptr x, mp_rnd_t rnd_mode) mpfr_can_round (__mpfr_const_log2, __gmpfr_const_log2_prec - 1, __mpfr_const_log2_rnd, rnd_mode, precx)) { - mpfr_set (x, __mpfr_const_log2, rnd_mode); - return; + return mpfr_set (x, __mpfr_const_log2, rnd_mode); } } - + /* need to recompute */ if (precx < LOG2_THRESHOLD) /* use nai"ve Taylor series evaluation */ { @@ -184,4 +183,5 @@ mpfr_const_log2 (mpfr_ptr x, mp_rnd_t rnd_mode) mpfr_set (__mpfr_const_log2, x, rnd_mode); __gmpfr_const_log2_prec = precx; __mpfr_const_log2_rnd = rnd_mode; + return 1; } |