fn cosh64(x: f64) f64
fn cosh64(x: f64) f64 { const u = @as(u64, @bitCast(x)); const w = @as(u32, @intCast(u >> 32)) & (maxInt(u32) >> 1); const ax = @as(f64, @bitCast(u & (maxInt(u64) >> 1))); // TODO: Shouldn't need this explicit check. if (x == 0.0) { return 1.0; } // |x| < log(2) if (w < 0x3FE62E42) { if (w < 0x3FF00000 - (26 << 20)) { if (x != 0) { math.raiseInexact(); } return 1.0; } const t = math.expm1(ax); return 1 + t * t / (2 * (1 + t)); } // |x| < log(DBL_MAX) if (w < 0x40862E42) { const t = @exp(ax); // NOTE: If x > log(0x1p26) then 1/t is not required. return 0.5 * (t + 1 / t); } // |x| > log(CBL_MAX) or nan return expo2(ax); }