0

Why when decreasing decimal part after 10.0000000000000008 the comparison returning True?

>>> 10 == 10.000000000000001
False
>>> 10 == 10.0000000000000001
True
Antony
  • 585
  • 2
  • 6
  • 14
  • That is normal behavior for floating point numbers. It has to do with resolution on the machine; in simple terms: the second number is close enough to 10 to be considered equal in floating point logic – Ralf Jul 11 '19 at 19:06
  • 2
    Because `10.0000000000000001` *is* 10 within the precision available to you. The mapping from valid `float` literals to valid `float` *values* is many-to-one. – chepner Jul 11 '19 at 19:06

0 Answers0