Skip to content

Constant Numbers

Justin Conklin edited this page Aug 24, 2017 · 1 revision

When you use 42 or 42.0 in Clojure, you are (in general) using instances of Long and Double, respectively. However, the :ldc instruction will assume you meant to load a primitive int or float value when said values are used with it. This is to alleviate having to manually cast numbers when ints and floats are required, like [:ldc (int 42)], which would be tedious and error-prone.

Insn provides the :ldc2 instruction instead, with the sole purpose of loading constant long and double values. :ldc is used to load all other constant values.