RunningSum
FinalYes
Neumaier-compensated float sum; exact (decimal) addition goes through Calculator.
Methods
- __construct() : mixed
- add() : void
- addAll() : void
- add() over every value, the compensated loop inlined: one call per batch, not per value.
- emptyPartial() : array{int: int, float: null, compensation: float}
- fromPartial() : self
- merge() : void
- partial() : array{int: null|int, float: null|float, compensation: float}
- partialType() : StructureType
- value() : float|int
- valueOf() : float|int
Methods
__construct()
public
__construct([Calculator $calculator = new Calculator() ]) : mixed
Parameters
- $calculator : Calculator = new Calculator()
add()
public
add(float|int|numeric-string $value, bool $exact) : void
Parameters
- $value : float|int|numeric-string
- $exact : bool
addAll()
add() over every value, the compensated loop inlined: one call per batch, not per value.
public
addAll(array<string|int, float|int|numeric-string> $values, bool $exact) : void
Parameters
- $values : array<string|int, float|int|numeric-string>
- $exact : bool
emptyPartial()
public
static emptyPartial() : array{int: int, float: null, compensation: float}
Return values
array{int: int, float: null, compensation: float} —the partial of a sum nothing was added to
fromPartial()
public
static fromPartial(array<string|int, mixed> $partial[, Calculator $calculator = new Calculator() ]) : self
Parameters
- $partial : array<string|int, mixed>
-
the shape of partial()
- $calculator : Calculator = new Calculator()
Tags
Return values
selfmerge()
public
merge(self $other, bool $exact) : void
Parameters
- $other : self
- $exact : bool
partial()
public
partial() : array{int: null|int, float: null|float, compensation: float}
Return values
array{int: null|int, float: null|float, compensation: float} —exactly one of int and float is set
partialType()
public
static partialType() : StructureType
Return values
StructureTypevalue()
public
value() : float|int
Return values
float|intvalueOf()
public
static valueOf(array{int: null|int, float: null|float, compensation: float} $partial) : float|int
Parameters
- $partial : array{int: null|int, float: null|float, compensation: float}
-
the shape of partial()