Floating point limitation
print(0.1 + 0.2) # 0.30000000000000004
x = 0.1 + 0.2
y = 0.3
print(x) # 0.30000000000000004
print(y) # 0.3
if x == y:
print("They are equal")
else:
print("They are NOT equal")
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
print(0.1 + 0.2) # 0.30000000000000004
x = 0.1 + 0.2
y = 0.3
print(x) # 0.30000000000000004
print(y) # 0.3
if x == y:
print("They are equal")
else:
print("They are NOT equal")