diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-05-12 14:57:10 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-05-12 14:57:10 +0000 |
commit | 7ae2b8ad31c98f6d322b137989132c99be903b44 (patch) | |
tree | 5b8f1374b196142ab61269f0ea56029b0ad0fe0c /tan.c | |
parent | 04a58918b7168f2ada6041123c83149d5c627796 (diff) | |
download | mpfr-7ae2b8ad31c98f6d322b137989132c99be903b44.tar.gz |
Simplify the code.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2913 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tan.c')
-rw-r--r-- | tan.c | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -25,7 +25,7 @@ MA 02111-1307, USA. */ int mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) { - int precy, m, ok, inexact; + int precy, m, inexact; mpfr_t s, c; if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x))) @@ -38,7 +38,6 @@ mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) else /* x is zero */ { MPFR_ASSERTD(MPFR_IS_ZERO(x)); - MPFR_CLEAR_FLAGS(y); MPFR_SET_ZERO(y); MPFR_SET_SAME_SIGN(y, x); MPFR_RET(0); @@ -52,21 +51,17 @@ mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_init2 (s, m); mpfr_init2 (c, m); - do + for (;;) { mpfr_sin_cos (s, c, x, GMP_RNDN); /* err <= 1/2 ulp on s and c */ mpfr_div (c, s, c, GMP_RNDN); /* err <= 2 ulps */ - ok = mpfr_can_round (c, m - 1, GMP_RNDN, GMP_RNDZ, - precy + (rnd_mode == GMP_RNDN)); - - if (ok == 0) - { - m += BITS_PER_MP_LIMB; - mpfr_set_prec (s, m); - mpfr_set_prec (c, m); - } + if (MPFR_IS_INF(x) || mpfr_can_round (c, m - 1, GMP_RNDN, GMP_RNDZ, + precy + (rnd_mode == GMP_RNDN))) + break; + m += BITS_PER_MP_LIMB; + mpfr_set_prec (s, m); + mpfr_set_prec (c, m); } - while (!ok); inexact = mpfr_set (y, c, rnd_mode); |