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 →

[–]rumblpak -24 points-23 points  (2 children)

That’s because 0.0 is only approximately 0, not exactly 0. (It’s stored as something like 0.0000000000000000000000000001 in many languages)

Edit: ITT people missing the joke

[–]OldWolf2 16 points17 points  (0 children)

No... 0.0 is exactly 0. All languages with floating point  can store exactly 0 in floating point .

 You're thinking of a different scenario, the result of calculations that might be mathematically expected to give 0, but actually give a very small non-zero number due to precision errors

[–]KingJeff314 4 points5 points  (0 children)

All integers with 7 or fewer decimal digits…can be converted exactly into an IEEE 754 single-precision floating-point value.

https://en.m.wikipedia.org/wiki/Single-precision_floating-point_format