Gnoseed
Programming · Flashcard

What does 0.1 + 0.2 == 0.3 evaluate to?

Why this is the answer

Binary floating point cannot represent 0.1 or 0.2 exactly, so their sum is 0.30000000000000004 and the comparison is False. No rounding is applied before ==, which does compare values (identity is is), and decimal literals are converted to the nearest binary double — use math.isclose() or the decimal module when exactness matters.

Read more in the docs
Study in Gnoseed →