1pub fn modf(x: f64) -> (f64, f64) {
2 let rv2: f64;
3 let mut u = x.to_bits();
4 let mask: u64;
5 let e = ((u >> 52 & 0x7ff) as i32) - 0x3ff;
6
7 /* no fractional part */
8 if e >= 52 {
9 rv2 = x;
10 if e == 0x400 && (u << 12) != 0 {
11 /* nan */
12 return (x, rv2);
13 }
14 u &= 1 << 63;
15 return (f64::from_bits(u), rv2);
16 }
17
18 /* no integral part*/
19 if e < 0 {
20 u &= 1 << 63;
21 rv2 = f64::from_bits(u);
22 return (x, rv2);
23 }
24
25 mask = ((!0) >> 12) >> e;
26 if (u & mask) == 0 {
27 rv2 = x;
28 u &= 1 << 63;
29 return (f64::from_bits(u), rv2);
30 }
31 u &= !mask;
32 rv2 = f64::from_bits(u);
33 return (x - rv2, rv2);
34}
35