xref: /inferno-os/libmath/fdlibm/s_isnan.c (revision 7ef44d652ae9e5e1f5b3465d73684e4a54de73c0)
1 /* derived from /netlib/fdlibm */
2 
3 /* @(#)s_isnan.c 1.3 95/01/18 */
4 /*
5  * ====================================================
6  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7  *
8  * Developed at SunSoft, a Sun Microsystems, Inc. business.
9  * Permission to use, copy, modify, and distribute this
10  * software is freely granted, provided that this notice
11  * is preserved.
12  * ====================================================
13  */
14 
15 /*
16  * isnan(x) returns 1 is x is nan, else 0;
17  * no branching!
18  */
19 
20 #include "fdlibm.h"
21 
22 	int isnan(double x)
23 {
24 	int hx,lx;
25 	hx = (__HI(x)&0x7fffffff);
26 	lx = __LO(x);
27 	hx |= (unsigned)(lx|(-lx))>>31;
28 	hx = 0x7ff00000 - hx;
29 	return ((unsigned)(hx))>>31;
30 }
31