Back to index

glibc  2.9
s_isnan.c
Go to the documentation of this file.
00001 /* @(#)s_isnan.c 5.1 93/09/24 */
00002 /*
00003  * ====================================================
00004  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00005  *
00006  * Developed at SunPro, a Sun Microsystems, Inc. business.
00007  * Permission to use, copy, modify, and distribute this
00008  * software is freely granted, provided that this notice
00009  * is preserved.
00010  * ====================================================
00011  */
00012 
00013 #if defined(LIBM_SCCS) && !defined(lint)
00014 static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
00015 #endif
00016 
00017 /*
00018  * isnan(x) returns 1 is x is nan, else 0;
00019  * no branching!
00020  */
00021 
00022 #include "math.h"
00023 #include "math_private.h"
00024 
00025 #ifdef __STDC__
00026        int __isnan(double x)
00027 #else
00028        int __isnan(x)
00029        double x;
00030 #endif
00031 {
00032        int32_t hx,lx;
00033        EXTRACT_WORDS(hx,lx,x);
00034        hx &= 0x7fffffff;
00035        hx |= (u_int32_t)(lx|(-lx))>>31;
00036        hx = 0x7ff00000 - hx;
00037        return (int)(((u_int32_t)hx)>>31);
00038 }
00039 hidden_def (__isnan)
00040 weak_alias (__isnan, isnan)
00041 #ifdef NO_LONG_DOUBLE
00042 strong_alias (__isnan, __isnanl)
00043 weak_alias (__isnan, isnanl)
00044 #endif