summaryrefslogtreecommitdiff
path: root/log1p.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-14 11:49:06 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-14 11:49:06 +0000
commit1fa2277c10582baa8b8402b8cf1702116ccbc560 (patch)
tree672209195ecad922dc489260098588b4dca469ad /log1p.c
parent51aef80e83eaf2fc76dd6be59c0549e890dccd2b (diff)
downloadmpfr-1fa2277c10582baa8b8402b8cf1702116ccbc560.tar.gz
replaced mpfr_can_round (approx, err, rnd1, GMP_RNDN, prec)
by mpfr_can_round (approx, err, rnd1, GMP_RNDZ, prec + 1) which in addition guarantees a correct inexact flag git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2492 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'log1p.c')
-rw-r--r--log1p.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/log1p.c b/log1p.c
index a913fe026..7bd641f7a 100644
--- a/log1p.c
+++ b/log1p.c
@@ -95,35 +95,37 @@ mpfr_log1p (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
long int err; /* Precision of error */
/* compute the precision of intermediary variable */
- Nt=MAX(Nx,Ny);
+ Nt = MAX(Nx,Ny);
/* the optimal number of bits : see algorithms.ps */
- Nt=Nt+5+__gmpfr_ceil_log2(Nt);
+ Nt = Nt + 5 + __gmpfr_ceil_log2 (Nt);
/* initialise of intermediary variable */
- mpfr_init(t);
+ mpfr_init (t);
/* First computation of cosh */
- do {
-
- /* reactualisation of the precision */
- mpfr_set_prec(t, Nt);
+ do
+ {
+ /* reactualisation of the precision */
+ mpfr_set_prec (t, Nt);
- /* compute log1p */
- mpfr_add_ui (t, x, 1, GMP_RNDN); /* 1+x */
- mpfr_log (t, t, GMP_RNDN); /* log(1+x)*/
-
- /* estimation of the error */
- /*err=Nt-(__gmpfr_ceil_log2(1+pow(2,1-MPFR_GET_EXP(t))));*/
- err = Nt - (MAX (1 - MPFR_GET_EXP (t), 0) + 1);
+ /* compute log1p */
+ mpfr_add_ui (t, x, 1, GMP_RNDN); /* 1+x */
+ mpfr_log (t, t, GMP_RNDN); /* log(1+x)*/
- /* actualisation of the precision */
- Nt += 10;
+ /* estimation of the error */
+ /*err=Nt-(__gmpfr_ceil_log2(1+pow(2,1-MPFR_GET_EXP(t))));*/
+ err = Nt - (MAX (1 - MPFR_GET_EXP (t), 0) + 1);
- } while ((err<0) || !mpfr_can_round(t, err, GMP_RNDN, rnd_mode, Ny));
+ /* actualisation of the precision */
+ Nt += 10;
+ }
+ while ((err < 0) || !mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ,
+ Ny + (rnd_mode == GMP_RNDN)));
inexact = mpfr_set (y, t, rnd_mode);
- mpfr_clear(t);
+ mpfr_clear (t);
}
+
return inexact;
}