In my python program, an if statement is not being entered. I have simplified the code to the following:
x = -5
while x < 5:
if (x == 0):
print 0
x += .01
This program does not output anything.
However, changing the last line to x += .5 makes the program output 0. What’s the problem?
Floating point number representation might not be accurate enough. You should never test for zero equality but instead use something along