Constructor
new Accumulator(yopt)
Accurate summation of many numbers.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
y |
number | Accumulator |
<optional> |
0 | set sum = y. |
Methods
Add(yopt)
Add a number to the accumulator.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
y |
number |
<optional> |
0 | set sum += y. |
Negate()
Set sum = −sum.
Remainder(y)
Take the remainder
Parameters:
Name | Type | Description |
---|---|---|
y |
number | the divisor of the remainder operation. |
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. |
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. |
Returns:
sum + y.