about summary refs log tree commit diff stats
path: root/506math.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-15 19:49:52 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-15 19:49:52 -0700
commit74151efc043c984ae328be599417570a8b75ff0f (patch)
treecef52e95620cfc4311f6b125b3558f25eeb42156 /506math.mu
parentc4475d83b747475663ad089b63169df88842be51 (diff)
downloadmu-74151efc043c984ae328be599417570a8b75ff0f.tar.gz
reimplement Bresenham line in Mu
Diffstat (limited to '506math.mu')
-rw-r--r--506math.mu21
1 files changed, 21 insertions, 0 deletions
diff --git a/506math.mu b/506math.mu
new file mode 100644
index 00000000..d4e4194c
--- /dev/null
+++ b/506math.mu
@@ -0,0 +1,21 @@
+fn abs n: int -> _/eax: int {
+  compare n, 0
+  {
+    break-if->=
+    negate n
+  }
+  return n
+}
+
+fn sgn n: int -> _/eax: int {
+  compare n, 0
+  {
+    break-if-<=
+    return 1
+  }
+  {
+    break-if->=
+    return -1
+  }
+  return 0
+}