It\'s well known that comparing floats for equality is a little fiddly due to rounding and precision issues.
For example: https://randomascii.wordpress.com/2012/02/2
To compare up to a given decimal without atol/rtol:
atol/rtol
def almost_equal(a, b, decimal=6): return '{0:.{1}f}'.format(a, decimal) == '{0:.{1}f}'.format(b, decimal) print(almost_equal(0.0, 0.0001, decimal=5)) # False print(almost_equal(0.0, 0.0001, decimal=4)) # True