summaryrefslogtreecommitdiff
path: root/tanh.c
diff options
context:
space:
mode:
Diffstat (limited to 'tanh.c')
-rw-r--r--tanh.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/tanh.c b/tanh.c
index 9ff5420f7..d30f18b4a 100644
--- a/tanh.c
+++ b/tanh.c
@@ -94,7 +94,7 @@ mpfr_tanh (y, xt, rnd_mode)
mp_prec_t Ny = MPFR_PREC(y); /* Precision of input variable */
mp_prec_t Nt; /* Precision of the intermediary variable */
- mp_prec_t err; /* Precision of error */
+ long int err; /* Precision of error */
/* compute the precision of intermediary variable */
Nt=MAX(Nx,Ny);
@@ -129,15 +129,12 @@ mpfr_tanh (y, xt, rnd_mode)
d = MPFR_EXP(te)-MPFR_EXP(t);
/* estimation of the error */
- if ((int)(Nt) < (int) (_mpfr_ceil_log2(7+pow(2,d+1))) )
- err = 0;
- else
- err = Nt-(_mpfr_ceil_log2(7+pow(2,d+1)));
+ err = Nt-(_mpfr_ceil_log2(7+pow(2,d+1)));
/* actualisation of the precision */
Nt += 10;
- } while (!mpfr_can_round(t,err,GMP_RNDN,rnd_mode,Ny));
+ } while ((err <0)||!mpfr_can_round(t,err,GMP_RNDN,rnd_mode,Ny));
if (flag_neg==1)
MPFR_CHANGE_SIGN(t);
@@ -148,6 +145,7 @@ mpfr_tanh (y, xt, rnd_mode)
mpfr_clear(ta);
mpfr_clear(tb);
}
+ mpfr_clear(x);
return inexact;
}