]>
git.proxmox.com Git - rustc.git/blob - vendor/libm/src/math/coshf.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.
11 #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
12 pub fn coshf(mut x
: f32) -> f32 {
13 let x1p120
= f32::from_bits(0x7b800000); // 0x1p120f === 2 ^ 120
16 let mut ix
= x
.to_bits();
18 x
= f32::from_bits(ix
);
23 if w
< (0x3f800000 - (12 << 23)) {
24 force_eval
!(x
+ x1p120
);
28 return 1. + t
* t
/ (2. * (1. + t
));
31 /* |x| < log(FLT_MAX) */
34 return 0.5 * (t
+ 1. / t
);
37 /* |x| > log(FLT_MAX) or nan */