Comparing floating-point numbers
#1
I'm down crazy (angry) with lua tonight:

function func1()
LOG(var1);
LOG(var2);
LOG("type var1 is ".. type(var1));
LOG("type var2 is ".. type(var2));

LOG("var1 - var2 = ".. (var1 - var2));

if var1 == var2 then
  LOG("EQ");
else
  LOG("NEQ");
end

Output:
Code:
Log: [02:05:47] 0.8
Log: [02:05:47] 0.8
Log: [02:05:47] type var1 is number
Log: [02:05:47] type var2 is number
Log: [02:05:47] var1 - var2 = -1.1102230246252e-16
Log: [02:05:47] NEQ
Reply
Thanks given by:


Messages In This Thread
Comparing floating-point numbers - by DrMasik - 12-20-2015, 10:08 AM
RE: Comparing floating-point numbers - by DrMasik - 12-20-2015, 09:48 PM
RE: Comparing floating-point numbers - by jan64 - 12-20-2015, 10:13 PM
RE: Comparing floating-point numbers - by DrMasik - 12-20-2015, 10:48 PM
RE: Comparing floating-point numbers - by jan64 - 12-21-2015, 07:11 AM



Users browsing this thread: 1 Guest(s)