Quote:
Originally Posted by amagalma
how one can do maths, if the maths you do are applied to different values and not to the ones you thought?...
|
For starters, don't equality compare floating point numbers :
Code:
if firstend == secondstart
It's a pretty rare occasion when you can truly expect 2 floats to be equal if they come from some source that is not entirely under your control.
You can compare their absolute difference to some value though :
Code:
local a = 0.000000001
local b = 0.000000001007
if math.abs(a-b)<0.00000000001 then print("approx equal")
else print("not equal") end
It is left up to you to decide what is that acceptable difference...