Python Float Division Not Exact
Possible Duplicate: Python float - str - float weirdness Python float division does not appear to have accurate results. Can someone explain why? >>>3.0/5 0.59999999999
Solution 1:
Short answer: Floats use finite-precision binary encoding to represent numbers, so various operations lose some precision.
The Wikipedia page has a lot of information (maybe too much).
See also: How do I use accurate float arithmetic in Python?
Solution 2:
Floating point arithmetic is not exact; there are rounding errors that are worsened by the fact that computers use binary floating point and not decimal floating point. See Wikipedia.
Post a Comment for "Python Float Division Not Exact"