2 ms·
Repeated summation can compound rounding errors and reduce the effective precision of floating point encoded numbers. Doubles have ~16 decimal digits of precis
by kloch 4y ago
Repeated summation can compound rounding errors and reduce the effective precision of floating point encoded numbers.
Doubles have ~16 decimal digits of precision but adding a billion doubles together sequentially (simple summation) could with worst case data reduce your effective precision to only ~7 digits. Random data would tend to have a sqrt(n) effect which would leave you with ~11 digits.
Several algorithms have been devised to reduce or even eliminate this effect. Kahan summation for example typically results in the precision loss of a single addition, effectively eliminating the compound errors. https://en.wikipedia.org/wiki/Kahan_summation_algorithm https://en.wikipedia.org/wiki/Kahan_summation_algorithm