1 /* s_isnanl.c -- long double version for i387 of s_isnan.c.
2  */
3 
4 /*
5  * ====================================================
6  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7  *
8  * Developed at SunPro, 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 #if defined(LIBM_SCCS) && !defined(lint)
16 static char rcsid[] = "$NetBSD: $";
17 #endif
18 
19 /*
20  * isnanl(x) returns 1 is x is nan, else 0;
21  * no branching!
22  */
23 
24 #include <math.h>
25 #include <math_private.h>
26 
__isnanl(long double x)27 int __isnanl(long double x)
28 {
29 	int32_t se,hx,lx,pn;
30 	GET_LDOUBLE_WORDS(se,hx,lx,x);
31 	se = (se & 0x7fff) << 1;
32 	/* Detect pseudo-normal numbers, i.e. exponent is non-zero and the top
33 	   bit of the significand is not set.   */
34 	pn = (uint32_t)((~hx & 0x80000000) & (se|(-se)))>>31;
35 	/* Clear the significand bit when computing mantissa.  */
36 	lx |= hx & 0x7fffffff;
37 	se |= (uint32_t)(lx|(-lx))>>31;
38 	se = 0xfffe - se;
39 
40 	return (int)(((uint32_t)(se)) >> 16) | pn;
41 }
42 hidden_def (__isnanl)
43 weak_alias (__isnanl, isnanl)
44