math: rewrite remainder functions (remainder, remquo, fmod, modf)
[musl] / src / math / __fpclassifyl.c
1 #include "libm.h"
2
3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4
5 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
6 /* invalid representations (top bit of u.i.m is wrong) are not handled */
7 int __fpclassifyl(long double x)
8 {
9         union ldshape u = {x};
10         int e = u.i.se & 0x7fff;
11         if (!e)
12                 return u.i.m ? FP_SUBNORMAL : FP_ZERO;
13         if (e == 0x7fff)
14                 return u.i.m << 1 ? FP_NAN : FP_INFINITE;
15         return FP_NORMAL;
16 }
17 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
18 int __fpclassifyl(long double x)
19 {
20         union ldshape u = {x};
21         int e = u.i.se & 0x7fff;
22         if (!e)
23                 return u.i2.lo | u.i2.hi ? FP_SUBNORMAL : FP_ZERO;
24         if (e == 0x7fff) {
25                 u.i.se = 0;
26                 return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE;
27         }
28         return FP_NORMAL;
29 }
30 #endif