HelenBlack / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

sum(..) functions will break is there's a numeric overflow for the type in question. #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Add this one to SumTest.java :

    @Test
    public void testSumMaxInteger() {
        assertThatSum(Integer.MAX_VALUE, Integer.MAX_VALUE-1, is(equalTo(????)));
    }

It is possible that where overflows are detected, the following promotions 
should happen:-

   short -> int -> long -> BigInteger
   float -> double -> BigDecimal

And if the topmost value overflows, then some failure is communicated to the 
developer at runtime.

Original issue reported on code.google.com by PaulHamm...@gmail.com on 2 Sep 2010 at 1:42

GoogleCodeExporter commented 8 years ago
That will cause an inconsistent behavior with the method:

<T> T sum(Object iterable, T argument)

that couldn't follow the same promotion politic in order to avoid a 
ClassCastException.

Original comment by mario.fu...@gmail.com on 20 Dec 2010 at 10:25