0

We have these three values:
x = 7.68
y = 7.775
z = 7.87

It happens that y-x = z-y = 0.095, but Python insists on assigning the following values:
y-x = 0.09500000000000064
z-y = 0.094999999999999975

It is an insignificant difference, but enough to return wrong results, for example:
y-x == z-y returns False, which is not true, the comparison should return True (0.095 == 0.095)

The fact is that those types of results are throwing me a comparison routine and the function returns me wrong results for it. How could you avoid this, if possible without using "external" typo sympy modules?

Lvdvig
  • 9
  • 2

0 Answers0