[PATCH] 8178117: Add public state constructors for Int/Long/DoubleSummaryStatistics
Joseph D. Darcy
joe.darcy at oracle.com
Wed Apr 12 17:59:29 UTC 2017
On 4/11/2017 1:48 PM, Chris Dennis wrote:
> Color me confused… what would the javadoc on the parameter say? It could I guess have an @implNote documenting the meanings of the parameters… but then what use is it? The proposed API simply limits the precision with which a DoubleSummaryStatistic can be copied to be the same as the precision with which it can be “accessed”. That doesn’t seem an enormous problem since I suspect that bulk of usages would be to marshall a “finished” instance and therefore there is no real loss occuring. If we wanted to support arbitrary precision wouldn’t it be better to have a constructor variant that took a BigDecimal, and a matching getPreciseSum() that returned a BigDecimal?
>
The javadoc would say something like "takes an array of double values
representing a sum." In other words, rather than forcing the in-progress
sum to be represented as a single double, it could be represented as
more than one double.
The current implementation basically uses two doubles internally to
represent the on-going summation. This extra state prevents many
numerically poor outcomes occurring when computing the sum. Greater
accuracy would be possible if additional internal state were used.
-Joe
More information about the core-libs-dev
mailing list