/rust/registry/src/index.crates.io-1949cf8c6b5b557f/libm-0.2.11/src/math/frexp.rs
Line | Count | Source |
1 | 0 | pub fn frexp(x: f64) -> (f64, i32) { |
2 | 0 | let mut y = x.to_bits(); |
3 | 0 | let ee = ((y >> 52) & 0x7ff) as i32; |
4 | | |
5 | 0 | if ee == 0 { |
6 | 0 | if x != 0.0 { |
7 | 0 | let x1p64 = f64::from_bits(0x43f0000000000000); |
8 | 0 | let (x, e) = frexp(x * x1p64); |
9 | 0 | return (x, e - 64); |
10 | 0 | } |
11 | 0 | return (x, 0); |
12 | 0 | } else if ee == 0x7ff { |
13 | 0 | return (x, 0); |
14 | 0 | } |
15 | | |
16 | 0 | let e = ee - 0x3fe; |
17 | 0 | y &= 0x800fffffffffffff; |
18 | 0 | y |= 0x3fe0000000000000; |
19 | 0 | return (f64::from_bits(y), e); |
20 | 0 | } |