Hello,

Testing (eventually) revealed that changing the streams floating point sum and average algorithms to use compensated summation (JDK-8006572 DoubleStream.sum() & DoubleSummaryStats implementations that reduce numerical errors), changed the behavior of the code on streams with infinite values: NaN was returned instead of infinity:

8030212: Several api.java.util.stream tests got "NaN" value instead of "Infinity" or "-Infinity"

The specification doesn't explicitly state how non-finite values in streams should be handled (and it should be updated to do so in 9, JDK-8030942 Explicitly state floating-point summation requirements on non-finite inputs), but it isn't unreasonable to assume that a properly signed infinity should result.

Towards that end, I've prepared a webrev that uses an additional simple sum to distinguish a spurious NaN sum in the result:

    http://cr.openjdk.java.net/~darcy/8030212.1/

This may not be the optimal way to track this situation, additional logic in the compensated summation code is possible, but if needed the implementation can be refined in JDK 9 and the 8 updates.

Thanks,

-Joe

Reply via email to