Clojure Q&A - Recent questions tagged long
https://ask.clojure.org/index.php/tag/long
*unchecked-math* true does not work for (long) fn
https://ask.clojure.org/index.php/8983/unchecked-math-true-does-not-work-for-long-fn
<p>It seems that unchecked-math does not turn (long) into (unchecked-long), but it does for (int). I believe this is a bug, or if not, I'm not sure why, since as a user, I'd expect the unchecked-math flag to turn all fns that have an equivalent unchecked- variant into that one.</p>
<pre><code>(set! *unchecked-math* true)
(decompile (int (nth [1 2 3] 1)))
;; RT.uncheckedIntCast(RT.nth(const__5, RT.uncheckedIntCast(1L)));
(decompile (long (nth [1 2 3] 1)))
;; Numbers.num(RT.longCast(RT.nth(const__5, RT.uncheckedIntCast(1L))));
(set! *unchecked-math* false)
(decompile (int (nth [1 2 3] 1)))
;; RT.intCast(RT.nth(const__5, RT.intCast(1L)));
(decompile (long (nth [1 2 3] 1)))
;; Numbers.num(RT.longCast(RT.nth(const__5, RT.intCast(1L))));
</code></pre>
<p>Logged: <a rel="nofollow" href="https://clojure.atlassian.net/browse/CLJ-2551">https://clojure.atlassian.net/browse/CLJ-2551</a></p>
Compilerhttps://ask.clojure.org/index.php/8983/unchecked-math-true-does-not-work-for-long-fnThu, 02 Jan 2020 22:40:35 +0000