DoubleAdder extends Number implements Comparable<DoubleAdder> { public DoubleAdder add(final double value) { addWithCompensation(value); _simpleSum += value; return this; } DoubleAdder(final double value);  DoubleAdder(); DoubleAdder set(final double value); DoubleAdder set(final DoubleAdder value); DoubleAdder add(final double value); DoubleAdder add(final double[] values); DoubleAdder add(final DoubleAdder value); DoubleAdder combine(final DoubleAdder other); double value(); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override int compareTo(final DoubleAdder other); boolean sameState(final DoubleAdder other); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); static double sum(final double[] values);  }
@Test public void add() { final int size = 1_000_000; final Random random = new Random(12349); final List<Double> numbers = new ArrayList<>(size); for (int i = 1; i <= size; ++i) { numbers.add(random.nextDouble()*i*1_000_000); } final DoubleAdder adder = new DoubleAdder(); numbers.forEach(adder::add); final double expectedSum = numbers.stream() .collect(summarizingDouble(Double::doubleValue)) .getSum(); Assert.assertEquals(adder.doubleValue(), expectedSum); }