An arbitrary-precision integer represents numbers beyond the limits of a signed long. Clojure's BigInt arithmetic automatically promotes results past Long/MIN_VALUE or Long/MAX_VALUE, subject to available memory. section 5.2 section 5.12
Use the quoted integer operators when calculations may exceed fixed-width limits:
- Use +', -', *', inc', and dec' for arbitrary-precision integer arithmetic. section 5.12
- Keep integer operands as integers; convert floating-point inputs to BigDecimal before using these operators. section 5.12
- Expect Java interoperation when using functionality implemented by java.math.BigInteger, including conversions to and from BigInt. section 5.12
Promotion at the long boundary
The ordinary fixed-precision operators can overflow at the long limits, while (+’ Long/MAX_VALUE 1) produces a BigInt instead of wrapping. A literal such as 2N also has type clojure.lang.BigInt. section 5.2 section 5.12
Large-number cryptography
A simplified Diffie-Hellman implementation uses BigInt for large modulus and exponent calculations, while converting to BigInteger to call Java's probable-prime and modular-exponentiation methods. section 5.12
Listing 5.9. → Integer Math, High Precision Arithmetic, Numeric Processing
(+' ([]) ([x]) ([x y]) ([x y & more])) (*' ([]) ([x]) ([x y]) ([x y & more])) (-' ([x]) ([x y]) ([x y & more])) (inc' [x]) (dec' [x])
Shows the supported arities for the core arbitrary-precision arithmetic operators. section 5.12



