1#include <math.h>
2#include <stdint.h>
3
4int __fpclassify(double x) {
5    union {
6        double f;
7        uint64_t i;
8    } u = {x};
9    int e = u.i >> 52 & 0x7ff;
10    if (!e)
11        return u.i << 1 ? FP_SUBNORMAL : FP_ZERO;
12    if (e == 0x7ff)
13        return u.i << 12 ? FP_NAN : FP_INFINITE;
14    return FP_NORMAL;
15}
16