/rust/registry/src/index.crates.io-1949cf8c6b5b557f/libm-0.2.16/src/math/frexpf.rs
Line | Count | Source |
1 | | #[cfg_attr(assert_no_panic, no_panic::no_panic)] |
2 | 0 | pub fn frexpf(x: f32) -> (f32, i32) { |
3 | 0 | let mut y = x.to_bits(); |
4 | 0 | let ee: i32 = ((y >> 23) & 0xff) as i32; |
5 | | |
6 | 0 | if ee == 0 { |
7 | 0 | if x != 0.0 { |
8 | 0 | let x1p64 = f32::from_bits(0x5f800000); |
9 | 0 | let (x, e) = frexpf(x * x1p64); |
10 | 0 | return (x, e - 64); |
11 | | } else { |
12 | 0 | return (x, 0); |
13 | | } |
14 | 0 | } else if ee == 0xff { |
15 | 0 | return (x, 0); |
16 | 0 | } |
17 | | |
18 | 0 | let e = ee - 0x7e; |
19 | 0 | y &= 0x807fffff; |
20 | 0 | y |= 0x3f000000; |
21 | 0 | (f32::from_bits(y), e) |
22 | 0 | } |