summaryrefslogtreecommitdiff
path: root/src/math/signbit.c
blob: 77cc3977f4985201769be04669d00d7fe40fc7b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <math.h>

#define signbit(__x) \
	(sizeof(__x) == sizeof(long double) ? \
		((((union { \
			long double __f; \
			char __c[sizeof(__x)]; \
		}){.__f = (__x)}).__c[sizeof(__x)-1] & 0x80) == 0x80 ? 1 : 0) : \
	sizeof(__x) == sizeof(double) ? \
		((((union { \
			double __f; \
			char __c[sizeof(__x)]; \
		}){.__f = (__x)}).__c[sizeof(__x)-1] & 0x80) == 0x80 ? 1 : 0) : \
		(((union { \
			float __f; \
			char __c[sizeof(__x)]; \
		}){.__f = (__x)}).__c[sizeof(__x)-1] & 0x80) == 0x80 ? 1 : 0)


/*
STDC(199901)
LINK(m)
*/