kahanSum {PreciseSums} | R Documentation |
Using the Kahan method, take a more accurate sum
Description
Using the Kahan method, take a more accurate sum
Usage
kahanSum(numbers)
Arguments
numbers |
A vector of numbers to sum. |
Value
Sum of numbers
References
https://en.wikipedia.org/wiki/Kahan_summation_algorithm
Examples
sum(c(1,1e100,1,-1e100)) ## Should be 2, gives 0
kahanSum(c(1,1e100,1,-1e100)) ## Not accurate enough for the correct result. (still = 0)
[Package PreciseSums version 0.6 Index]