transmute(type)x; Minor code clean up

This commit is contained in:
Ginger Bill
2017-07-30 14:52:42 +01:00
parent 655931f0ea
commit 62a72f0163
16 changed files with 805 additions and 185 deletions
+6 -6
View File
@@ -60,19 +60,19 @@ sign :: proc(x: f64) -> f64 { if x >= 0 do return +1; return -1; }
copy_sign :: proc(x, y: f32) -> f32 {
ix := transmute(u32, x);
iy := transmute(u32, y);
ix := transmute(u32)x;
iy := transmute(u32)y;
ix &= 0x7fff_ffff;
ix |= iy & 0x8000_0000;
return transmute(f32, ix);
return transmute(f32)ix;
}
copy_sign :: proc(x, y: f64) -> f64 {
ix := transmute(u64, x);
iy := transmute(u64, y);
ix := transmute(u64)x;
iy := transmute(u64)y;
ix &= 0x7fff_ffff_ffff_ff;
ix |= iy & 0x8000_0000_0000_0000;
return transmute(f64, ix);
return transmute(f64)ix;
}
round :: proc(x: f32) -> f32 { if x >= 0 do return floor(x + 0.5); return ceil(x - 0.5); }