1 const FP_ILOGBNAN: i32 = -1 - 0x7fffffff; 2 const FP_ILOGB0: i32 = FP_ILOGBNAN; 3 ilogb(x: f64) -> i324pub fn ilogb(x: f64) -> i32 { 5 let mut i: u64 = x.to_bits(); 6 let e = ((i >> 52) & 0x7ff) as i32; 7 8 if e == 0 { 9 i <<= 12; 10 if i == 0 { 11 force_eval!(0.0 / 0.0); 12 return FP_ILOGB0; 13 } 14 /* subnormal x */ 15 let mut e = -0x3ff; 16 while (i >> 63) == 0 { 17 e -= 1; 18 i <<= 1; 19 } 20 e 21 } else if e == 0x7ff { 22 force_eval!(0.0 / 0.0); 23 if (i << 12) != 0 { 24 FP_ILOGBNAN 25 } else { 26 i32::max_value() 27 } 28 } else { 29 e - 0x3ff 30 } 31 } 32