In a two's-complement system, values always have one more negative
number than positive number. -2147483648 (being the most negative int)
has no positive equivalent that can be expressed as an int (Math/abs
overloads on primitive type).

Sean's example using 1.3.0-SNAPSHOT works because literal numbers are
now read in as longs or doubles.  This is also why the original (Math/
abs (- Integer/MIN_VALUE 1)) gave the desired result as the int was
converted to a long via the subtraction function.

Of course, the same "problem" would arise if one tried to use the most
negative long:

user=> (Math/abs Long/MIN_VALUE)
-9223372036854775808

The unsurprising behavior might be for a clojure abs function to
instead throw an ArithmeticException, since 9223372036854775808 cannot
be expressed as a long.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to