/*
* Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
* Public domain.
*/
#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!
*/
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
#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!
*/
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)
#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!
*/
{
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)