ArithmeticException signals an invalid numeric operation in Clojure, commonly integer division by zero, long overflow, or a non-terminating decimal expansion. section 5.5
Watch for these failure cases:
- Dividing by zero with / throws an ArithmeticException. section 5.5
- Adding, subtracting, or multiplying long values beyond Long/MAX_VALUE or below Long/MIN_VALUE throws for integer overflow. section 5.5
- Some BigDecimal divisions produce a non-terminating decimal expansion and require attention to precision. section 5.5
Overflow during lazy computation
(take 7 (iterate #(* % %) 2)) ;; ArithmeticException integer overflow (take 7 (iterate #(*' % %) 2)) ;; (2 4 16 256 65536 4294967296 18446744073709551616N)
