1 | pub fn frexpf(x: f32) -> (f32, i32) { |
---|---|
2 | let mut y: u32 = x.to_bits(); |
3 | let ee: i32 = ((y >> 23) & 0xff) as i32; |
4 | |
5 | if ee == 0 { |
6 | if x != 0.0 { |
7 | let x1p64: f32 = f32::from_bits(0x5f800000); |
8 | let (x: f32, e: i32) = frexpf(x * x1p64); |
9 | return (x, e - 64); |
10 | } else { |
11 | return (x, 0); |
12 | } |
13 | } else if ee == 0xff { |
14 | return (x, 0); |
15 | } |
16 | |
17 | let e: i32 = ee - 0x7e; |
18 | y &= 0x807fffff; |
19 | y |= 0x3f000000; |
20 | (f32::from_bits(y), e) |
21 | } |
22 |