xref: /freebsd/lib/msun/src/s_isnan.c (revision f9218d3d4fd34f082473b3a021c6d4d109fb47cf)
1 /* @(#)s_isnan.c 5.1 93/09/24 */
2 /*
3  * ====================================================
4  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5  *
6  * Developed at SunPro, a Sun Microsystems, Inc. business.
7  * Permission to use, copy, modify, and distribute this
8  * software is freely granted, provided that this notice
9  * is preserved.
10  * ====================================================
11  */
12 
13 /* For binary compat; to be removed in FreeBSD 6.0. */
14 
15 #ifndef lint
16 static char rcsid[] = "$FreeBSD$";
17 #endif
18 
19 /*
20  * isnan(x) returns 1 is x is nan, else 0;
21  * no branching!
22  */
23 
24 #include "math.h"
25 #include "math_private.h"
26 
27 #undef isnan
28 
29 	int isnan(double x)
30 {
31 	int32_t hx,lx;
32 	EXTRACT_WORDS(hx,lx,x);
33 	hx &= 0x7fffffff;
34 	hx |= (u_int32_t)(lx|(-lx))>>31;
35 	hx = 0x7ff00000 - hx;
36 	return (int)((u_int32_t)(hx))>>31;
37 }
38