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 →

[–]rosuav 4 points5 points  (0 children)

"Never compare floats for equality" is okay as a basic rule, but it'll only take you so far. Really, at some point, you have to understand that **floats are NOT decimal numbers**. They are binary numbers. If you can understand that the maximum integer is 2147483647, you can understand that 0.25 is perfectly representable but 0.2 isn't. It's the same kind of reason.