aboutsummaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2020-12-06 00:49:48 +0000
committerGitHub <noreply@github.com>2020-12-06 00:49:48 +0000
commitf0683c910231513db9adab83f7c2fca9dd8d2613 (patch)
tree2539634b5b71caf5148d8927c9298ba20bad5246 /core/math
parent54fbdabc380905a925ab5e922749fa2b1ccb2621 (diff)
parentca4657fd31b9efc7ab52f7e1b6f4145d5ed28fb7 (diff)
Merge branch 'master' into parser-experiments
Diffstat (limited to 'core/math')
-rw-r--r--core/math/math.odin24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/math/math.odin b/core/math/math.odin
index fb463c08d..ee93a4d8c 100644
--- a/core/math/math.odin
+++ b/core/math/math.odin
@@ -593,6 +593,30 @@ is_inf :: proc{is_inf_f32, is_inf_f64};
+inf_f32 :: proc(sign: int) -> f32 {
+ return f32(inf_f64(sign));
+}
+inf_f64 :: proc(sign: int) -> f64 {
+ v: u64;
+ if sign >= 0 {
+ v = 0x7ff00000_00000000;
+ } else {
+ v = 0xfff00000_00000000;
+ }
+ return transmute(f64)v;
+}
+
+
+nan_f32 :: proc() -> f32 {
+ return f32(nan_f64());
+}
+nan_f64 :: proc() -> f64 {
+ v: u64 = 0x7ff80000_00000001;
+ return transmute(f64)v;
+}
+
+
+
is_power_of_two :: proc(x: int) -> bool {
return x > 0 && (x & (x-1)) == 0;
}