#exercise 2.21 from A primer... a = (1/947.0)*947 b=1 #Checking for equality does not work: if a != b: print('Wrong result! The numbers should be equal...') """ Here we check if the numbers are equal to a tolerance. We invert the test to make the output more meaningful. """ tol = 1e-10 if abs(a-b) < tol: print('Now it is correct. The numbers are equal.') """ Terminal> python compare_floats.py Wrong result! The numbers should be equal... Now it is correct. The numbers are equal. """