xref: /haiku/src/system/libroot/posix/glibc/arch/generic/s_isinf.c (revision 901f399036a25e35a7931af6209a327c21dd4dcf)
1*901f3990SIngo Weinhold /*
2*901f3990SIngo Weinhold  * Written by J.T. Conklin <jtc@netbsd.org>.
3*901f3990SIngo Weinhold  * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
4*901f3990SIngo Weinhold  * Public domain.
5*901f3990SIngo Weinhold  */
6*901f3990SIngo Weinhold 
7*901f3990SIngo Weinhold #if defined(LIBM_SCCS) && !defined(lint)
8*901f3990SIngo Weinhold static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
9*901f3990SIngo Weinhold #endif
10*901f3990SIngo Weinhold 
11*901f3990SIngo Weinhold /*
12*901f3990SIngo Weinhold  * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
13*901f3990SIngo Weinhold  * no branching!
14*901f3990SIngo Weinhold  */
15*901f3990SIngo Weinhold 
16*901f3990SIngo Weinhold #include "math.h"
17*901f3990SIngo Weinhold #include "math_private.h"
18*901f3990SIngo Weinhold 
19*901f3990SIngo Weinhold int
__isinf(double x)20*901f3990SIngo Weinhold __isinf (double x)
21*901f3990SIngo Weinhold {
22*901f3990SIngo Weinhold 	int32_t hx,lx;
23*901f3990SIngo Weinhold 	EXTRACT_WORDS(hx,lx,x);
24*901f3990SIngo Weinhold 	lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
25*901f3990SIngo Weinhold 	lx |= -lx;
26*901f3990SIngo Weinhold 	return ~(lx >> 31) & (hx >> 30);
27*901f3990SIngo Weinhold }
28*901f3990SIngo Weinhold hidden_def (__isinf)
29*901f3990SIngo Weinhold weak_alias (__isinf, isinf)
30*901f3990SIngo Weinhold #ifdef NO_LONG_DOUBLE
31*901f3990SIngo Weinhold strong_alias (__isinf, __isinfl)
32*901f3990SIngo Weinhold weak_alias (__isinf, isinfl)
33*901f3990SIngo Weinhold #endif
34