1#include "libm.h" 2 3#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 4long double asinhl(long double x) { 5 return asinh(x); 6} 7#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 8/* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */ 9long double asinhl(long double x) { 10 union ldshape u = {x}; 11 unsigned e = u.i.se & 0x7fff; 12 unsigned s = u.i.se >> 15; 13 14 /* |x| */ 15 u.i.se = e; 16 x = u.f; 17 18 if (e >= 0x3fff + 32) { 19 /* |x| >= 0x1p32 or inf or nan */ 20 x = logl(x) + 0.693147180559945309417232121458176568L; 21 } else if (e >= 0x3fff + 1) { 22 /* |x| >= 2 */ 23 x = logl(2 * x + 1 / (sqrtl(x * x + 1) + x)); 24 } else if (e >= 0x3fff - 32) { 25 /* |x| >= 0x1p-32 */ 26 x = log1pl(x + x * x / (sqrtl(x * x + 1) + 1)); 27 } else { 28 /* |x| < 0x1p-32, raise inexact if x!=0 */ 29 FORCE_EVAL(x + 0x1p120f); 30 } 31 return s ? -x : x; 32} 33#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 34// TODO: broken implementation to make things compile 35long double asinhl(long double x) { 36 return asinh(x); 37} 38#endif 39