Back to index

glibc  2.9
s_isinf.c
Go to the documentation of this file.
00001 /*
00002  * Written by J.T. Conklin <jtc@netbsd.org>.
00003  * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
00004  * Public domain.
00005  */
00006 
00007 #if defined(LIBM_SCCS) && !defined(lint)
00008 static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
00009 #endif
00010 
00011 /*
00012  * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
00013  * no branching!
00014  */
00015 
00016 #include "math.h"
00017 #include "math_private.h"
00018 
00019 int
00020 __isinf (double x)
00021 {
00022        int32_t hx,lx;
00023        EXTRACT_WORDS(hx,lx,x);
00024        lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
00025        lx |= -lx;
00026        return ~(lx >> 31) & (hx >> 30);
00027 }
00028 hidden_def (__isinf)
00029 weak_alias (__isinf, isinf)
00030 #ifdef NO_LONG_DOUBLE
00031 strong_alias (__isinf, __isinfl)
00032 weak_alias (__isinf, isinfl)
00033 #endif