1 #include <math.h>
2 #include <sys/types.h>
3 #include <libm.h>
4 
fabs(double x)5 double fabs(double x)
6 {
7     union
8     {
9         double f;
10         uint64_t i;
11     } u = {x};
12     u.i &= -1ULL / 2;
13     return u.f;
14 }
15 
16 
17 #if __LDBL_MANT_DIG__ == 53 &&  __LDBL_MAX_EXP__ == 1024
fabsl(long double x)18 long double fabsl(long double x)
19 {
20 	return fabs(x);
21 }
22 #elif (__LDBL_MANT_DIG__ == 64 || __LDBL_MANT_DIG__ == 113) && __LDBL_MAX_EXP__ == 16384
fabsl(long double x)23 long double fabsl(long double x)
24 {
25 	union ldshape u = {x};
26 
27 	u.i.se &= 0x7fff;
28 	return u.f;
29 }
30 #endif