Class: Accumulator

geodesic/Accumulator.Accumulator(yopt)

This allows many numbers to be added together with twice the normal precision. In the documentation of the member functions, sum stands for the value currently held in the accumulator.

Constructor

new Accumulator(yopt)

Accurate summation of many numbers.

Parameters:
Name Type Attributes Default Description
y number | Accumulator <optional>
0

set sum = y.

Source:

Methods

Add(yopt)

Add a number to the accumulator.

Parameters:
Name Type Attributes Default Description
y number <optional>
0

set sum += y.

Source:

Negate()

Set sum = −sum.

Source:

Remainder(y)

Take the remainder

Parameters:
Name Type Description
y number

the divisor of the remainder operation.

Source:
Returns:

sum in range [−y/2, y/2].

Set(yopt)

Set the accumulator to a number.

Parameters:
Name Type Attributes Default Description
y number | Accumulator <optional>
0

set sum = y.

Source:

Sum(yopt)

Return the result of adding a number to sum (but don't change sum).

Parameters:
Name Type Attributes Default Description
y number <optional>
0

the number to be added to the sum.

Source:
Returns:

sum + y.