October 2025
Intermediate to advanced
100 pages
2h 27m
English
It might look like we’re adding 0.1 and 0.2, but your computer does its sums in binary, not decimal. To squeeze those numbers into a CPU-friendly 64 binary digits, or bits, Kotlin has to round each one up by a tiny amount. Adding the two rounded values also adds together those two small rounding errors, producing a result that’s noticeably larger than 0.3.
Your computer is an adding machine that works by summing pairwise digits. To see why that can produce some imprecise outputs, let’s try using the same approach with some two-digit decimals. Unlike a computer, we won’t have any trouble with 0.1 + 0.2:

But some numbers ...
Read now
Unlock full access