Floating point literal using 0x...p... in Rust?


Is there an equivalent to C++17 floating point literals using 0x...p...? E.g. 0x1p-64


I assume I can replace it by:

// 0x1p-64 = (2.0 as f32).powi(-64 as i32)
let x = (2.0 as f32).powi(-64 as i32)


That calculation only works in simple cases, when all the intermediate values can be represented exactly. The hexf crate offers exact hex literals, and they’re evaluated at compile time to boot.