summaryrefslogtreecommitdiff
path: root/hypot.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 /hypot.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 'hypot.c')
-rw-r--r--hypot.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/hypot.c b/hypot.c
index 10cc75f06..5f3319360 100644
--- a/hypot.c
+++ b/hypot.c
@@ -44,30 +44,28 @@ mpfr_hypot (mpfr_ptr z, mpfr_srcptr x , mpfr_srcptr y , mp_rnd_t rnd_mode)
mp_exp_unsigned_t diff_exp;
/* particular cases */
-
- if (MPFR_IS_NAN(x) || MPFR_IS_NAN(y))
- {
- MPFR_SET_NAN(z);
- MPFR_RET_NAN;
- }
-
- MPFR_CLEAR_NAN(z);
-
- if (MPFR_IS_INF(x) || MPFR_IS_INF(y))
+ if (MPFR_ARE_SINGULAR(x,y))
{
- MPFR_SET_INF(z);
- MPFR_SET_POS(z);
- MPFR_RET(0);
+ if (MPFR_IS_NAN(x) || MPFR_IS_NAN(y))
+ {
+ MPFR_SET_NAN(z);
+ MPFR_RET_NAN;
+ }
+ MPFR_CLEAR_NAN(z);
+ if (MPFR_IS_INF(x) || MPFR_IS_INF(y))
+ {
+ MPFR_SET_INF(z);
+ MPFR_SET_POS(z);
+ MPFR_RET(0);
+ }
+ MPFR_CLEAR_INF(z);
+ if (MPFR_IS_ZERO(x))
+ return mpfr_abs (z, y, rnd_mode);
+ if (MPFR_IS_ZERO(y))
+ return mpfr_abs (z, x, rnd_mode);
+ MPFR_ASSERTN(1);
}
- MPFR_CLEAR_INF(z);
-
- if (MPFR_IS_ZERO(x))
- return mpfr_abs (z, y, rnd_mode);
-
- if (MPFR_IS_ZERO(y))
- return mpfr_abs (z, x, rnd_mode);
-
if (mpfr_cmpabs (x, y) < 0)
{
mpfr_srcptr t;