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):
prin
This is a rounding issue - decimal values cannot be represented exactly in binary, so x never exactly equals 0.0000000000....
try replacing if (x == 0):
with if -0.001 < x < 0.001:
BTW, the parentheses are unnecessary in a python if
statement.
edit: Printing out the values between -1 and 1 in steps of 0.01 shows this is the case - where zero should be it prints 7.52869988574e-16.