Floating-Point Summation
Explore how errors in floating-point representation of real numbers accumulate during summation, leading to inaccuracies in calculations and programming tasks. Understand how these inaccuracies impact your code.
Real numbers are represented in computing as an approximation. Numbers with a common fraction in which the denominator is a power of two are stored as exact numbers: 1/2, 1/4, 3/8, etc. See the Floating-point arithmetics article on Wikipedia.
Some algorithms can reduce the numerical error which accumulates when adding real numbers in a sequence. For example, Kahan summation algorithm and its variations. Note: these algorithms work for three or more numbers.