/build/cargo-vendor-dir/libm-0.2.8/src/math/expo2.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use super::{combine_words, exp}; |
2 | | |
3 | | /* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */ |
4 | | #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] |
5 | 0 | pub(crate) fn expo2(x: f64) -> f64 { |
6 | 0 | /* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */ |
7 | 0 | const K: i32 = 2043; |
8 | 0 | let kln2 = f64::from_bits(0x40962066151add8b); |
9 | 0 |
|
10 | 0 | /* note that k is odd and scale*scale overflows */ |
11 | 0 | let scale = combine_words(((0x3ff + K / 2) as u32) << 20, 0); |
12 | 0 | /* exp(x - k ln2) * 2**(k-1) */ |
13 | 0 | exp(x - kln2) * scale * scale |
14 | 0 | } |