Why 0.1 + 0.2 ≠ 0.3 in Computers (Floating-Point Explained)
Tech Made Simple
0:00 / 0:00
Why 0.1 + 0.2 ≠ 0.3 in Computers (Floating-Point Explained)
9 просмотров · 5 дней назад
Tech Made Simple
3 подписчика
9 просмотров · 5 дней назад
Why does `0.1 + 0.2` sometimes produce `0.30000000000000004` instead of `0.3`?
It looks like a simple arithmetic mistake, but the real reason lies in how computers represent numbers.
In this video, we build the explanation from the ground up:
Why computers use binary instead of decimal.
Why fractions like `0.1` cannot be represented exactly in binary.
How limited precision creates rounding errors.
Why adding two approximations can produce a surprising result.
How floating-point rounding works and when exact equality can fail.
No advanced mathematics required. Just one small example that reveals a fundamental idea in computer science.
#Programming #ComputerScience #FloatingPoint