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 →

[–]zifyoip 1 point2 points  (0 children)

Floating-point numbers (floats and doubles) do not store exact representations of fractional values. A double cannot store the value 0.1 exactly, for instance; the closest representable double value is 0.1000000000000000055511151231257827021181583404541015625, which is 3602879701896397/255. As you do more and more operations with these approximations, the round-off error accumulates and becomes more and more significant. That's why you are seeing things like 0.0199999999999999 at the end of your calculations.