blob: f5965fbc753dee7432689c7605e7a9b75b3e6d3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* Adapted from cephes */
static int
isnan(double x)
{
union
{
double d;
unsigned short s[4];
unsigned int i[2];
} u;
u.d = x;
#if SIZEOF_INT == 4
#ifdef WORDS_BIGENDIAN /* defined in pyconfig.h */
if( ((u.i[0] & 0x7ff00000) == 0x7ff00000)
&& (((u.i[0] & 0x000fffff) != 0) || (u.i[1] != 0)))
return 1;
#else
if( ((u.i[1] & 0x7ff00000) == 0x7ff00000)
&& (((u.i[1] & 0x000fffff) != 0) || (u.i[0] != 0)))
return 1;
#endif
#else /* SIZEOF_INT != 4 */
#ifdef WORDS_BIGENDIAN
if( (u.s[0] & 0x7ff0) == 0x7ff0)
{
if( ((u.s[0] & 0x000f) | u.s[1] | u.s[2] | u.s[3]) != 0 )
return 1;
}
#else
if( (u.s[3] & 0x7ff0) == 0x7ff0)
{
if( ((u.s[3] & 0x000f) | u.s[2] | u.s[1] | u.s[0]) != 0 )
return 1;
}
#endif
#endif /* SIZEOF_INT */
return 0;
}
|