JDK 8 code review request forJDK-8024354: Explicitly permit DoubleStream.sum()/average() implementations to use higher precision summation

Paul Sandoz paul.sandoz at oracle.com
Wed Oct 9 18:36:11 UTC 2013


On Oct 9, 2013, at 3:56 AM, Joe Darcy <joe.darcy at oracle.com> wrote:

> Hello,
> 
> Please review the patch below which addresses
> 
>        JDK-8024354 Explicitly permit DoubleStream.sum()/average() implementations to use higher precision summation
> 
> Thanks,
> 

The note feels more like an api note since it leaves me wondering what does the current implementation does. Presumably we should mention that current impl does do not do anything special?

Paul.

> -Joe
> 
> diff -r f1e31376f419 src/share/classes/java/util/DoubleSummaryStatistics.java
> --- a/src/share/classes/java/util/DoubleSummaryStatistics.java Wed Oct 09 00:10:02 2013 +0100
> +++ b/src/share/classes/java/util/DoubleSummaryStatistics.java Tue Oct 08 18:54:55 2013 -0700
> @@ -118,6 +118,11 @@
>      * value is a {@code NaN} or the sum is at any point a {@code NaN} then the
>      * sum will be {@code NaN}.
>      *
> +     * @implNote This method may be implemented using compensated
> +     * summation or other technique to reduce the error bound in the
> +     * numerical sum compared to a simple summation of {@code double}
> +     * values.
> +     *
>      * @return the sum of values, or zero if none
>      */
>     public final double getSum() {
> @@ -161,6 +166,10 @@
>      * value is a {@code NaN} or the sum is at any point a {@code NaN} then the
>      * average will be {@code NaN}.
>      *
> +     * @implNote This method may be implemented using compensated
> +     * summation or other technique to reduce the error bound in the
> +     * numerical sum used to compute the average.
> +     *
>      * @return the arithmetic mean of values, or zero if none
>      */
>     public final double getAverage() {
> 



More information about the core-libs-dev mailing list