kahanSum: Using the Kahan method, take a more accurate sum

Description Usage Arguments Value References Examples

View source: R/sums.R

Description

Using the Kahan method, take a more accurate sum

Usage

1
kahanSum(numbers)

Arguments

numbers

A vector of numbers to sum.

Value

Sum of numbers

References

https://en.wikipedia.org/wiki/Kahan_summation_algorithm

Examples

1
2
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)

PreciseSums documentation built on July 10, 2020, 5:13 p.m.