because the max positive integer is not 2147483648 but 2147483647 because the 0 is also considered a positive int. so if you have an int of 2147483648, it is out of range. The couter of int goes: 2147483646 2147483647 -2147483648 -2147483647
This is explicity addressed in the Java Language Specification for the Unary Minus Operator -:
For integer values, negation is the same as subtraction from zero. The Java programming language uses two's-complement representation for integers, and the range of two's-complement values is not symmetric, so negation of the maximum negative int or long results in that same maximum negative number. Overflow occurs in this case, but no exception is thrown. For all integer values x, -x equals (~x)+1.
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
Joined: Feb 15, 2007
All clear now. Thenks guys for explaining that
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com