blob: d128cb1fb72efec3d9cd4be8de3d593901243460 (
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
|
/* Adapted from cephes */
static int
signbit(double x)
{
union
{
double d;
short s[4];
int i[2];
} u;
u.d = x;
#if SIZEOF_INT == 4
#ifdef WORDS_BIGENDIAN /* defined in pyconfig.h */
return u.i[0] < 0;
#else
return u.i[1] < 0;
#endif
#else /* SIZEOF_INT != 4 */
#ifdef WORDS_BIGENDIAN
return u.s[0] < 0;
#else
return u.s[3] < 0;
#endif
#endif /* SIZEOF_INT */
}
|