From 837d5c5d0a2704ebfe48de3799936bf98330e134 Mon Sep 17 00:00:00 2001 From: Shagun Agrawal Date: Thu, 12 Dec 2024 00:07:27 +0530 Subject: Assembly codeden for long type Used clojure core match Added assembly phase --- src/cljcc/util.clj | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/cljcc/util.clj') diff --git a/src/cljcc/util.clj b/src/cljcc/util.clj index 6ced120..01eabd4 100644 --- a/src/cljcc/util.clj +++ b/src/cljcc/util.clj @@ -87,7 +87,7 @@ _ (-> strip-l-or-L Long/parseLong Long/toString)] - s) + s) (catch Exception _e false))) @@ -102,3 +102,17 @@ (exc/lex-error {:line line :col col}))) +(defn round-away-from-zero [num div] + (let [div (abs div)] + (cond + (= (mod num div) 0) num + (< num 0) (- num (- div (mod num div))) + :else (+ num (- div (mod num div)))))) + +(defn in-int-range? + "Verifies whether -2^31 <= x <= 2^31." + [v] + (and (>= v Integer/MIN_VALUE) + (<= v Integer/MAX_VALUE))) + +(not (in-int-range? Long/MAX_VALUE)) -- cgit v1.2.3