The methods for increment, decrement, and also negation test for exactly one value at the extremities of the value range. The verbosity of method calls in the source code and the overhead in the execution make these a poor choice for developers. If the code must really operate correctly at the extremities then the developer needs to carefully implement and check where appropriate. The checking for overflow in addition, subtraction, and multiplication are subtle or complex enough to warrant support in the runtime. Roger On 02/03/2012 01:00 PM, Stephen Colebourne wrote:
On 3 February 2012 17:52, Eamonn McManus<eamonn@mcmanus.net> wrote:
I agree with Stephen Colebourne that brief implementation comments would be useful. But I disagree with his proposed further methods in Math (increment, decrement, int+long variants), which I don't think would pull their weight. FWIW, JSR-310 currently has 18 non-test usages of increment/decrement, vs 42 uses of add. Less, but certainly used.
The real value in increment/decrement is that it becomes a simple mapping from operator to method a++ = increment(a) a-- = decrement(a) a + b = add(a, b) This makes it easier to see what the intent would have been were the real operators safe.
Stephen