Code example for BigDecimal

Methods: doubleValue, subtract

0
        deciSum = deciSum.add( new BigDecimal(in) );
    } 
 
    public double getSum() { 
        log.info("Got BigDecimal "+deciSum+" v. double " + sum );
        BigDecimal diff = deciSum.subtract(new BigDecimal(sum));
        if( diff.doubleValue() != 0.0 ) {
            log.severe("Kahan summation disagrees with BigDecimal by "+diff);
        } 
        return sum;
    } 
}