Re: Dealing with floats
Posted: Thu Jul 28, 2016 7:13 pm
my bad, posted the code while i was still playing with it.
@pgimeno
Never heard of mantissa. Gonna read it now. Thanks for the heads up.
Code: Select all
function equals( x, y )
if math.abs(x) >= 1000 and math.abs(y) >= 1000 then
eps = 10
elseif math.abs(x) >= 100 and math.abs(y) >= 100 then
eps = 5
elseif math.abs(x) >= 10 and math.abs(y) >= 10 then
eps = 1
else
eps = 0.1
end
return math.abs( x - y ) <= ( eps )
end
Never heard of mantissa. Gonna read it now. Thanks for the heads up.