public CompensatedSum add ( CompensatedSum other ) { double correctedSum = other . value ( ) + ( delta + other . delta ( ) ) ; double updatedValue = value + correctedSum ; double updatedDelta = correctedSum - ( updatedValue - value ) ; return new CompensatedSum ( updatedValue , updatedDelta ) ; }
Increments the Kahan sum by adding two sums and updating the correction term for reducing numeric errors .