9
Just in case anyone stumbles on this one:, here's my somehow shorter version:
function sign(x)
return x>0 and 1 or x<0 and -1 or 0
end
You can check for the sign like this:
i = -2
if i == math.abs(i) then -- or i >= 0
print "positive"
else
print "negative"
end