Is there a way to do accurate floating point division in Python?
Let's say I try to do the following mathematical operations.
0.6 / 0.3
returns2.0
which is correct. Cool, it looks like math is working!0.6 / 0.2
returns2.9999999999999996
when3.0
would be the correct result.0.6 / 0.1
returns5.999999999999999
when6.0
would be the correct result.
I'm wondering if there is a simple solution to this issue that I'm totally missing?
Note: I have seen the answers for Is floating point math broken? and although many of the answers do an outstanding job of explaining floating point operations, it does not appear that any of the responses provide an actual solution on how to accurately do division with floating point values in Python.