summaryrefslogtreecommitdiff
path: root/chapter31/src/main/smp/sys/math.smp
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-11-14 12:41:16 -0800
committerCliff Click <cliffc@acm.org>2026-11-14 12:41:16 -0800
commit3d0f3f38d9d8345b6508b3289dc94b0500c53d9e (patch)
tree1b769cdc4e415fad5c1b18afa23ffc6fe56db18a /chapter31/src/main/smp/sys/math.smp
parentafcf96444366fb4b7c83f938763013cbc360aade (diff)
downloadSimple-3d0f3f38d9d8345b6508b3289dc94b0500c53d9e.tar.gz
Simple-3d0f3f38d9d8345b6508b3289dc94b0500c53d9e.zip
Breakout, Clock demos
Math lib with simple constants raw bit converters TypeConAry unified Big Formatting change Debug symbols for constant data IterPeeps was endlessly running asserts with much inlining RegAlloc rounds raised
Diffstat (limited to 'chapter31/src/main/smp/sys/math.smp')
-rw-r--r--chapter31/src/main/smp/sys/math.smp15
1 files changed, 15 insertions, 0 deletions
diff --git a/chapter31/src/main/smp/sys/math.smp b/chapter31/src/main/smp/sys/math.smp
new file mode 100644
index 00000000..a5e1887c
--- /dev/null
+++ b/chapter31/src/main/smp/sys/math.smp
@@ -0,0 +1,15 @@
+// Mathematical constants, rounded to the nearest f64 value.
+val PI = 3.141592653589793;
+val E = 2.718281828459045;
+
+// Fixed-semantics C bindings recognized by the compiler's intrinsic inliner.
+// These preserve all 64 bits, including signed zero and NaN payloads.
+// They are NOT numeric conversions (ordinary typed assignments still are).
+{ f64 -> i64 } simple_f64_bits = "C";
+{ i64 -> f64 } simple_f64_from_bits = "C";
+val f64Bits = simple_f64_bits;
+val f64FromBits = simple_f64_from_bits;
+
+
+val max = { f64 x, f64 y -> return x > y ? x : y; };
+val min = { f64 x, f64 y -> return x < y ? x : y; };