From: Ulrich Drepper Date: Mon, 17 Mar 1997 04:08:05 +0000 (+0000) Subject: Rewrite to return -1 for -inf. X-Git-Tag: cvs/glibc-2_0_4~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1908c0864174733623fdc1de5126956594a78baf;p=thirdparty%2Fglibc.git Rewrite to return -1 for -inf. --- diff --git a/sysdeps/libm-ieee754/s_isinf.c b/sysdeps/libm-ieee754/s_isinf.c index b35fc1c41c5..d3c2cb55b72 100644 --- a/sysdeps/libm-ieee754/s_isinf.c +++ b/sysdeps/libm-ieee754/s_isinf.c @@ -1,5 +1,6 @@ /* * Written by J.T. Conklin . + * Changed to return -1 for -Inf by Ulrich Drepper . * Public domain. */ @@ -8,7 +9,7 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $"; #endif /* - * isinf(x) returns 1 is x is inf, else 0; + * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0; * no branching! */ @@ -22,12 +23,12 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $"; double x; #endif { - int32_t hx,lx; + u_int32_t hx; + int32_t lx; EXTRACT_WORDS(hx,lx,x); - hx &= 0x7fffffff; - hx ^= 0x7ff00000; - hx |= lx; - return (hx == 0); + lx |= (hx & 0x7fffffff) ^ 0x7ff00000; + lx |= -lx; + return ~(lx >> 31) & (1 - ((hx >> 30) & 2)); } weak_alias (__isinf, isinf) #ifdef NO_LONG_DOUBLE diff --git a/sysdeps/libm-ieee754/s_isinff.c b/sysdeps/libm-ieee754/s_isinff.c index 1d81f159861..9acc0df6ec9 100644 --- a/sysdeps/libm-ieee754/s_isinff.c +++ b/sysdeps/libm-ieee754/s_isinff.c @@ -8,7 +8,7 @@ static char rcsid[] = "$NetBSD: s_isinff.c,v 1.3 1995/05/11 23:20:21 jtc Exp $"; #endif /* - * isinff(x) returns 1 is x is inf, else 0; + * isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0; * no branching! */ @@ -22,10 +22,11 @@ static char rcsid[] = "$NetBSD: s_isinff.c,v 1.3 1995/05/11 23:20:21 jtc Exp $"; float x; #endif { - int32_t ix; + int32_t ix,t; GET_FLOAT_WORD(ix,x); - ix &= 0x7fffffff; - ix ^= 0x7f800000; - return (ix == 0); + t = ix & 0x7fffffff; + t ^= 0x7f800000; + t |= -t; + return ~(t >> 31) & (1 - ((ix & 0x80000000) >> 30)); } weak_alias (__isinff, isinff) diff --git a/sysdeps/libm-ieee754/s_isinfl.c b/sysdeps/libm-ieee754/s_isinfl.c index 22dff75444d..b4998214419 100644 --- a/sysdeps/libm-ieee754/s_isinfl.c +++ b/sysdeps/libm-ieee754/s_isinfl.c @@ -9,7 +9,7 @@ static char rcsid[] = "$NetBSD: $"; #endif /* - * isinfl(x) returns 1 is x is inf, else 0; + * isinfl(x) returns 1 if x is inf, -1 if x is -inf, else 0; * no branching! */ @@ -25,9 +25,9 @@ static char rcsid[] = "$NetBSD: $"; { int32_t se,hx,lx; GET_LDOUBLE_WORDS(se,hx,lx,x); - se &= 0x7fff; - se ^= 0x7fff; - se |= hx | lx; - return (se == 0); + hx |= lx | ((se & 0x7fff) ^ 0x7fff); + hx |= -hx; + se &= 0x8000; + return ~(hx >> 31) & (1 - (se >> 14)); } weak_alias (__isinfl, isinfl)