aboutsummaryrefslogtreecommitdiff
path: root/core/math.odin
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2017-11-09 22:48:00 +0000
committergingerBill <bill@gingerbill.org>2017-11-09 22:48:00 +0000
commiteb4b3f5976d1563cd97841964e829fc638179cc5 (patch)
tree4031277bf8d44d261a5c8a10ad2c62aed9e3dbfb /core/math.odin
parentdbb070524ffde7d392c6776dae41ea440b0e84c6 (diff)
Change push allocator system; update core libraries
Diffstat (limited to 'core/math.odin')
-rw-r--r--core/math.odin19
1 files changed, 9 insertions, 10 deletions
diff --git a/core/math.odin b/core/math.odin
index 06bea2a28..e6edebca7 100644
--- a/core/math.odin
+++ b/core/math.odin
@@ -64,8 +64,8 @@ unlerp :: proc(a, b, x: f32) -> (t: f32) do return (x-a)/(b-a);
unlerp :: proc(a, b, x: f64) -> (t: f64) do return (x-a)/(b-a);
-sign :: proc(x: f32) -> f32 { if x >= 0 do return +1; return -1; }
-sign :: proc(x: f64) -> f64 { if x >= 0 do return +1; return -1; }
+sign :: proc(x: f32) -> f32 { return x >= 0 ? +1 : -1; }
+sign :: proc(x: f64) -> f64 { return x >= 0 ? +1 : -1; }
@@ -85,14 +85,14 @@ copy_sign :: proc(x, y: f64) -> f64 {
return transmute(f64)ix;
}
-round :: proc(x: f32) -> f32 { if x >= 0 do return floor(x + 0.5); return ceil(x - 0.5); }
-round :: proc(x: f64) -> f64 { if x >= 0 do return floor(x + 0.5); return ceil(x - 0.5); }
+round :: proc(x: f32) -> f32 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
+round :: proc(x: f64) -> f64 { return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5); }
-floor :: proc(x: f32) -> f32 { if x >= 0 do return f32(i64(x)); return f32(i64(x-0.5)); } // TODO: Get accurate versions
-floor :: proc(x: f64) -> f64 { if x >= 0 do return f64(i64(x)); return f64(i64(x-0.5)); } // TODO: Get accurate versions
+floor :: proc(x: f32) -> f32 { return x >= 0 ? f32(i64(x)) : f32(i64(x-0.5)); } // TODO: Get accurate versions
+floor :: proc(x: f64) -> f64 { return x >= 0 ? f64(i64(x)) : f64(i64(x-0.5)); } // TODO: Get accurate versions
-ceil :: proc(x: f32) -> f32 { if x < 0 do return f32(i64(x)); return f32(i64(x+1)); }// TODO: Get accurate versions
-ceil :: proc(x: f64) -> f64 { if x < 0 do return f64(i64(x)); return f64(i64(x+1)); }// TODO: Get accurate versions
+ceil :: proc(x: f32) -> f32 { return x < 0 ? f32(i64(x)) : f32(i64(x+1)); }// TODO: Get accurate versions
+ceil :: proc(x: f64) -> f64 { return x < 0 ? f64(i64(x)) : f64(i64(x+1)); }// TODO: Get accurate versions
remainder :: proc(x, y: f32) -> f32 do return x - round(x/y) * y;
remainder :: proc(x, y: f64) -> f64 do return x - round(x/y) * y;
@@ -141,8 +141,7 @@ norm :: proc(v: $T/[$N]$E) -> T do return v / mag(v);
norm0 :: proc(v: $T/[$N]$E) -> T {
m := mag(v);
- if m == 0 do return 0;
- return v/m;
+ return m == 0 ? 0 : v/m;
}