diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-14 11:49:06 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-10-14 11:49:06 +0000 |
commit | 1fa2277c10582baa8b8402b8cf1702116ccbc560 (patch) | |
tree | 672209195ecad922dc489260098588b4dca469ad /sinh.c | |
parent | 51aef80e83eaf2fc76dd6be59c0549e890dccd2b (diff) | |
download | mpfr-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 'sinh.c')
-rw-r--r-- | sinh.c | 52 |
1 files changed, 27 insertions, 25 deletions
@@ -94,39 +94,41 @@ mpfr_sinh (mpfr_ptr y, mpfr_srcptr xt, mp_rnd_t rnd_mode) mpfr_init (ti); /* First computation of sinh */ - do { + do + { - /* reactualisation of the precision */ + /* reactualisation of the precision */ - mpfr_set_prec (t, Nt); - mpfr_set_prec (te, Nt); - mpfr_set_prec (ti, Nt); + mpfr_set_prec (t, Nt); + mpfr_set_prec (te, Nt); + mpfr_set_prec (ti, Nt); - /* compute sinh */ - mpfr_exp (te, x, GMP_RNDD); /* exp(x) */ - mpfr_ui_div (ti, 1, te, GMP_RNDU); /* 1/exp(x) */ - mpfr_sub (t, te, ti, GMP_RNDN); /* exp(x) - 1/exp(x) */ - mpfr_div_2ui (t, t, 1, GMP_RNDN); /* 1/2(exp(x) - 1/exp(x)) */ + /* compute sinh */ + mpfr_exp (te, x, GMP_RNDD); /* exp(x) */ + mpfr_ui_div (ti, 1, te, GMP_RNDU); /* 1/exp(x) */ + mpfr_sub (t, te, ti, GMP_RNDN); /* exp(x) - 1/exp(x) */ + mpfr_div_2ui (t, t, 1, GMP_RNDN); /* 1/2(exp(x) - 1/exp(x)) */ - /* it may be that t is zero (in fact, it can only occur when te=1, - and thus ti=1 too) */ + /* it may be that t is zero (in fact, it can only occur when te=1, + and thus ti=1 too) */ - if (MPFR_IS_ZERO(t)) - err = -1; - else - { - /* calculation of the error */ - d = MPFR_GET_EXP (te) - MPFR_GET_EXP (t) + 2; + if (MPFR_IS_ZERO(t)) + err = -1; + else + { + /* calculation of the error */ + d = MPFR_GET_EXP (te) - MPFR_GET_EXP (t) + 2; - /* error estimate */ - /* err = Nt-(__gmpfr_ceil_log2(1+pow(2,d)));*/ - err = Nt - (MAX(d,0) + 1); - } + /* error estimate */ + /* err = Nt-(__gmpfr_ceil_log2(1+pow(2,d)));*/ + err = Nt - (MAX(d,0) + 1); + } - /* actualisation of the precision */ - Nt += 10; + /* actualisation of the precision */ + Nt += 10; - } while ((err < 0) || !mpfr_can_round(t, err, GMP_RNDN, rnd_mode, Ny)); + } while ((err < 0) || !mpfr_can_round (t, err, GMP_RNDN, GMP_RNDZ, + Ny + (rnd_mode == GMP_RNDN))); if (flag_neg == 1) MPFR_CHANGE_SIGN(t); |