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