Anyone have an idea if this would work on a big endian machine?
fn main() {
let a : f32 = 1.7;
let s : usize = unsafe { *((&a as *const f32) as *const usize) };
let b : f32 = unsafe { *((&s as *const usize) as *const f32) };
assert_eq!(a, b);
println!("{} {} {}", a, s, b);
}
Or is there some other hidden danger other than "Why the frick are you saving a float in an integer"?. Or is there a better way to do this assignment without a conversion?