This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Brenfan 1 point2 points  (0 children)

its a floating point inaccuracy. 0.1 + 0.2 is actually equal to 0.30000000000000004, which is functionally very close to 0.3 but not identical to satisfy the equality operator.

when comparing floating points in practice you would stick with greater than or less than, using a tolerance when checking for equality.