summaryrefslogtreecommitdiff
path: root/sin.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-28 16:31:13 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-28 16:31:13 +0000
commit117edf14c822a22cdd9c25689aeadc904a1a30d1 (patch)
treee39bd61cefc24cc6cfbc5b2b956e4fb36015d111 /sin.c
parent734c0a144b04e2cae4e67b394010e3f6e3cadecc (diff)
downloadmpfr-117edf14c822a22cdd9c25689aeadc904a1a30d1.tar.gz
Use of MPFR_UNLIKELY and MPFR_IS_SINGULAR for fast detection of special values (Nan, Inf or Zero).
Start to encapsulate the sign to be independant of the reprensation (Must be 1 or -1). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2525 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sin.c')
-rw-r--r--sin.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/sin.c b/sin.c
index 97df89fa6..eee56f359 100644
--- a/sin.c
+++ b/sin.c
@@ -90,18 +90,21 @@ mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
int precy, m, ok, e, inexact, sign;
mpfr_t c;
- if (MPFR_IS_NAN(x) || MPFR_IS_INF(x))
+ if (MPFR_UNLIKELY( MPFR_IS_SINGULAR(x) ))
{
- MPFR_SET_NAN(y);
- MPFR_RET_NAN;
- }
-
- if (MPFR_IS_ZERO(x))
- {
- MPFR_CLEAR_FLAGS(y);
- MPFR_SET_ZERO(y);
- MPFR_SET_SAME_SIGN(y, x);
- MPFR_RET(0);
+ if (MPFR_IS_NAN(x) || MPFR_IS_INF(x))
+ {
+ MPFR_SET_NAN(y);
+ MPFR_RET_NAN;
+ }
+ else if (MPFR_IS_ZERO(x))
+ {
+ MPFR_CLEAR_FLAGS(y);
+ MPFR_SET_ZERO(y);
+ MPFR_SET_SAME_SIGN(y, x);
+ MPFR_RET(0);
+ }
+ MPFR_ASSERTN(1);
}
precy = MPFR_PREC(y);
@@ -119,8 +122,8 @@ mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_ui_sub (c, 1, c, GMP_RNDN);
e = 2 + (- MPFR_GET_EXP (c)) / 2;
mpfr_sqrt (c, c, GMP_RNDN);
- if (sign < 0)
- mpfr_neg (c, c, GMP_RNDN);
+ if (MPFR_IS_NEG_SIGN(sign))
+ MPFR_CHANGE_SIGN(c);
/* the absolute error on c is at most 2^(e-m) = 2^(EXP(c)-err) */
e = MPFR_GET_EXP (c) + m - e;