Based on the following question:
How to convert hex string to a float in Rust?
I've tried the following code:
fn main() {
// Hex string to 8 bytes, aka. u64
let bytes = u64::from_str_radix("c51981cb", 16).unwrap();
// Reinterpret 8 bytes as f64:
let float = unsafe { std::mem::transmute::<u64, f64>(bytes) };
println!("float: {}", float);
}
This compiles and runs, but according to https://www.h-schmidt.net/FloatConverter/IEEE754.html, the answer should be -2456.11206055, rather than the 0.000.... number I'm getting.
Have I got a problem with BE/LE? Or am I making some other mistake?