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