JDK 8 and 9 RFR of 8030212: Several api.java.util.stream tests got "NaN" value instead of "Infinity" or "-Infinity"

Mike Duigou mike.duigou at oracle.com
Tue Dec 24 18:53:13 UTC 2013


Approved. These changes are a reasonable solution and, as you say, we can improve it further in future releases.

Mike

On Dec 22 2013, at 06:54 , Joe Darcy <joe.darcy at oracle.com> wrote:

> 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




More information about the core-libs-dev mailing list