[Solved] Not getting integer overflow in Clojure?
I am running Clojure 1.3.0 with La Clojure in IntelliJ IDEA while reading The Joy Of Clojure, and on section 4.1.3 (page 64), the authors demonstrate integer overflow with the following code:
(+ Integer/MAX_VALUE Integer/MAX_VALUE)
;=> java.lang.ArithmeticException: integer overflow
However, when I try it out on the REPL, I get instead
user=> (+ Integer/MAX_VALUE Integer/MAX_VALUE)
4294967294
user=> Integer/MAX_VALUE
2147483647
What is happening here? Why are my integers being added correctly instead of overflowing?
Read more here: Source link