]>
git.proxmox.com Git - rustc.git/blob - vendor/compiler_builtins/libm/src/math/cosh.rs
5 /// Hyperbolic cosine (f64)
7 /// Computes the hyperbolic cosine of the argument x.
8 /// Is defined as `(exp(x) + exp(-x))/2`
9 /// Angles are specified in radians.
10 #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
11 pub fn cosh(mut x
: f64) -> f64 {
13 let mut ix
= x
.to_bits();
14 ix
&= 0x7fffffffffffffff;
15 x
= f64::from_bits(ix
);
20 if w
< 0x3ff00000 - (26 << 20) {
21 let x1p120
= f64::from_bits(0x4770000000000000);
22 force_eval
!(x
+ x1p120
);
25 let t
= expm1(x
); // exponential minus 1
26 return 1. + t
* t
/ (2. * (1. + t
));
29 /* |x| < log(DBL_MAX) */
32 /* note: if x>log(0x1p26) then the 1/t is not needed */
33 return 0.5 * (t
+ 1. / t
);
36 /* |x| > log(DBL_MAX) or nan */