1pub fn frexp(x: f64) -> (f64, i32) {
2 let mut y: u64 = x.to_bits();
3 let ee: i32 = ((y >> 52) & 0x7ff) as i32;
4
5 if ee == 0 {
6 if x != 0.0 {
7 let x1p64: f64 = f64::from_bits(0x43f0000000000000);
8 let (x: f64, e: i32) = frexp(x * x1p64);
9 return (x, e - 64);
10 }
11 return (x, 0);
12 } else if ee == 0x7ff {
13 return (x, 0);
14 }
15
16 let e: i32 = ee - 0x3fe;
17 y &= 0x800fffffffffffff;
18 y |= 0x3fe0000000000000;
19 return (f64::from_bits(y), e);
20}
21