Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
Created August 13, 2020 06:38
Show Gist options
  • Save nixpulvis/eb6b3d7e78e82a7204740b3158d543d0 to your computer and use it in GitHub Desktop.
Save nixpulvis/eb6b3d7e78e82a7204740b3158d543d0 to your computer and use it in GitHub Desktop.
union U {
u32: u32,
u64: u64,
f32: f32,
f64: f64,
}
fn main() {
let u32 = U { u32: 1 };
let u64 = U { u64: 1 };
let f32 = U { f32: 1. };
let f64 = U { f64: 1. };
unsafe {
dbg!(u32.u32);
dbg!(u32.u64);
dbg!(u32.f32);
dbg!(u32.f64);
dbg!(u64.u32);
dbg!(u64.u64);
dbg!(u64.f32);
dbg!(u64.f64);
dbg!(f32.u32);
dbg!(f32.u64);
dbg!(f32.f32);
dbg!(f32.f64);
dbg!(f64.u32);
dbg!(f64.u64);
dbg!(f64.f32);
dbg!(f64.f64);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment