From e00e34402cc78feba66a5d7f7598f2001aa4d84e Mon Sep 17 00:00:00 2001 From: Tom Helmuth Date: Tue, 7 Nov 2023 20:43:24 -0500 Subject: [PATCH] Added float_div instruction --- src/propeller/push/instructions/numeric.cljc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/propeller/push/instructions/numeric.cljc b/src/propeller/push/instructions/numeric.cljc index ff47336..7de1e3c 100755 --- a/src/propeller/push/instructions/numeric.cljc +++ b/src/propeller/push/instructions/numeric.cljc @@ -183,6 +183,14 @@ Otherwise, acts as a NOOP" ;; FLOAT Instructions only ;; ============================================================================= +;; Divides the top two items on the float stack +;; If denominator is 0, returns 1.0 +(def-instruction + :float_div + ^{:stacks #{:float}} + (fn [state] + (make-instruction state #(float (if (zero? %2) 1 (/ %1 %2))) [:float :float] :float))) + ;; Pushes the cosine of the top FLOAT (def-instruction :float_cos