is_int(): Using math.floor()


#1

Why doesn't this work for x = -3.4? I take the absolute value first, so where is the error?

def is_int(x):
if abs(x) / math.floor(x) > 1 :
return False
else:
return True


#2

x = -3.4


abs(x) / math.floor(x) > 1
abs(-3.4) / math.floor(-3.4) > 1
3.4 / -4 > 1
-0.85 > 1
False

#3

Thanks, I floored the absolute value of x and now it works.