3 /* tanh(x) = (exp(x) - exp(-x))/(exp(x) + exp(-x))
4 * = (exp(2*x) - 1)/(exp(2*x) - 1 + 2)
5 * = (1 - exp(-2*x))/(exp(-2*x) - 1 + 2)
9 union {double f; uint64_t i;} u = {.f = x};
16 u.i &= (uint64_t)-1/2;
21 /* |x| > log(3)/2 ~= 0.5493 or nan */
24 /* note: this branch avoids raising overflow */
25 /* raise inexact if x!=+-inf and handle nan */
26 t = 1 + 0/(x + 0x1p-120f);
31 } else if (w > 0x3fd058ae) {
32 /* |x| > log(5/3)/2 ~= 0.2554 */
36 /* |x| is small, up to 2ulp error in [0.1,0.2554] */