Share via


DoubleSummaryStatistics.Sum Property

Definition

Returns the sum of values recorded, or zero if no values have been recorded.

public double Sum { [Android.Runtime.Register("getSum", "()D", "", ApiSince=24)] get; }
[<get: Android.Runtime.Register("getSum", "()D", "", ApiSince=24)>]
member this.Sum : double

Property Value

the sum of values, or zero if none

Attributes

Remarks

Returns the sum of values recorded, or zero if no values have been recorded.

The value of a floating-point sum is a function both of the input values as well as the order of addition operations. The order of addition operations of this method is intentionally not defined to allow for implementation flexibility to improve the speed and accuracy of the computed result.

In particular, 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 double values.

Because of the unspecified order of operations and the possibility of using differing summation schemes, the output of this method may vary on the same input values.

Various conditions can result in a non-finite sum being computed. This can occur even if the all the recorded values being summed are finite. If any recorded value is non-finite, the sum will be non-finite:

<ul>

<li>If any recorded value is a NaN, then the final sum will be NaN.

<li>If the recorded values contain one or more infinities, the sum will be infinite or NaN.

<ul>

<li>If the recorded values contain infinities of opposite sign, the sum will be NaN.

<li>If the recorded values contain infinities of one sign and an intermediate sum overflows to an infinity of the opposite sign, the sum may be NaN.

</ul>

</ul>

It is possible for intermediate sums of finite values to overflow into opposite-signed infinities; if that occurs, the final sum will be NaN even if the recorded values are all finite.

If all the recorded values are zero, the sign of zero is <em>not</em> guaranteed to be preserved in the final sum.

Java documentation for java.util.DoubleSummaryStatistics.getSum().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to