xref: /haiku/src/system/libroot/posix/musl/math/__fpclassify.c (revision f504f61099b010fbfa94b1cc63d2e9072c7f7185)
1*f504f610SAugustin Cavalier #include <math.h>
2*f504f610SAugustin Cavalier #include <stdint.h>
3*f504f610SAugustin Cavalier 
__fpclassify(double x)4*f504f610SAugustin Cavalier int __fpclassify(double x)
5*f504f610SAugustin Cavalier {
6*f504f610SAugustin Cavalier 	union {double f; uint64_t i;} u = {x};
7*f504f610SAugustin Cavalier 	int e = u.i>>52 & 0x7ff;
8*f504f610SAugustin Cavalier 	if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
9*f504f610SAugustin Cavalier 	if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE;
10*f504f610SAugustin Cavalier 	return FP_NORMAL;
11*f504f610SAugustin Cavalier }
12