Using the Kahan method, take a more accurate sum
kahanSum(numbers)
A vector of numbers to sum.
Sum of numbers
https://en.wikipedia.org/wiki/Kahan_summation_algorithm
# NOT RUN { 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) # }
Run the code above in your browser using DataCamp Workspace