Why 0.1 + 0.2 Isn't 0.3: The Hidden Pattern in Floating-Point Addition
Adding Floating-Point Decimals for Fun and Profit
Floating-point addition of decimals like 0.1 + 0.2 famously yields 0.30000000000000004, but the errors aren't random. By analyzing the ulp (unit in the last place) and the error function, the author shows that summing two multiples of 0.01 up to 1.00 produces a striking checkerboard pattern. The result can be at most one ulp off, and the pattern arises from interference between three copies of the error function. A deep dive into IEEE double-precision arithmetic and the Steele-White algorithm for decimal conversion.
Famously, with IEEE double-precision floats, 0.1 + 0.2 is not 0.3, but rather, 0.30000000000000004.