compiler_builtins/math/libm_math/
acosh.rs1use super::{log, log1p, sqrt};
2
3const LN2: f64 = 0.693147180559945309417232121458176568; #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
11pub fn acosh(x: f64) -> f64 {
12 let u = x.to_bits();
13 let e = ((u >> 52) as usize) & 0x7ff;
14
15 if e < 0x3ff + 1 {
18 return log1p(x - 1.0 + sqrt((x - 1.0) * (x - 1.0) + 2.0 * (x - 1.0)));
20 }
21 if e < 0x3ff + 26 {
22 return log(2.0 * x - 1.0 / (x + sqrt(x * x - 1.0)));
24 }
25 return log(x) + LN2;
27}