about summary refs log tree commit diff stats
path: root/408float.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-29 08:24:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-29 08:24:27 -0700
commite55d3f5814d0f243d9d6a51f05433c14f0939055 (patch)
tree3da63846ece6e84599abd02c30a71e4068448148 /408float.mu
parent54765018beb8a9c0dde67de527dbfedefdecaed0 (diff)
downloadmu-e55d3f5814d0f243d9d6a51f05433c14f0939055.tar.gz
maintain aspect ratio when rendering images
Diffstat (limited to '408float.mu')
-rw-r--r--408float.mu12
1 files changed, 12 insertions, 0 deletions
diff --git a/408float.mu b/408float.mu
index d1c04836..2753308b 100644
--- a/408float.mu
+++ b/408float.mu
@@ -21,3 +21,15 @@ fn rational nr: int, dr: int -> _/xmm0: float {
   result <- divide divisor
   return result
 }
+
+# n/m rounded up
+fn scale-down-and-round-up n: int, m: int -> _/ecx: int {
+  var result/ecx: int <- copy n
+  result <- add m
+  result <- decrement
+  var result-f/xmm0: float <- convert result
+  var m-f/xmm1: float <- convert m
+  result-f <- divide m-f
+  result <- truncate result-f
+  return result
+}