public class Accumulator extends Object
This allow many double precision numbers to be added together with twice the normal precision. Thus the effective precision of the sum is 106 bits or about 32 decimal places.
The implementation follows J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3) 305–363 (1997).
In the documentation of the member functions, sum stands for the value currently held in the accumulator.
| Constructor and Description |
|---|
Accumulator(Accumulator a)
Construct from another Accumulator.
|
Accumulator(double y)
Construct from a double.
|
| Modifier and Type | Method and Description |
|---|---|
void |
Add(double y)
Add a number to the accumulator.
|
void |
Negate()
Negate an accumulator.
|
void |
Set(double y)
Set the value to a double.
|
double |
Sum()
Return the value held in the accumulator.
|
double |
Sum(double y)
Return the result of adding a number to sum (but don't change
sum).
|
public Accumulator(double y)
y - set sum = y.public Accumulator(Accumulator a)
a - set sum = a.public void Set(double y)
y - set sum = y.public double Sum()
public double Sum(double y)
y - the number to be added to the sum.public void Add(double y)
y - set sum += y.public void Negate()
Set sum = −sum.
Copyright © 2017. All Rights Reserved.