Saturday, January 12, 2019

python - Compare approximate value to 6 decimal





I would like to ask how we can define a and b are actually same after approximation. I like to have True in the following case.



a = 59.9999999
b = 60.0000001
if (a==b):
print(True)

else:
print(False)

Answer



a = 59.9999999
b = 60.0000001
np.isclose([a],[b],atol =a-b)
#op
array([ True])


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...