Knowing the types of available numbers and their representations is not sufficient to understand how mathematics is modeled in Clojure. Clojure’s various arithmetic and equality operators provide additional semantic guarantees in order to support sensible results across all the numeric types in play and in the face of many common issues that arise in computational mathematics, such as the handling of overflow and underflow, controlling the promotion of arithmetic results, and collection equality.
The 64-bit range of longs and doubles is quite expansive; integers ±2^{63}-1 can be represented and operated on, along with decimals ±1.7976931348623157^{308}. Most applications have no need for additional range or precision, so longs and doubles are often perfectly sufficient.
For those applications that do require additional range and/or
precision, arbitrary precision numeric
representations are available. These representations are
always boxed; Clojure uses both clojure.lang.BigInt
and java.math.BigInteger
to represent arbitrary-range integers, and java.math.BigDecimal
for arbitrary-precision
decimals.