Legacy GM [SOLVED] math_set_epsilon() does it even work?

Pere

Member
So, I wanted to change the epsilon value to change at which decimal the == comparisons are rounded to calculate bbox'es... but it seems the epsilon functions don't work.

the epsilon is the value at which things are considered to be equal, for example:
if the epsilon is 0.01
then 0.0001 == 0.0002 would return true, right?

well, I set the epsilon to that and it returns false.

And after quite a lot of tests, I still haven't found changing the epsilon to make any difference at all....

WTF?
 

Pere

Member
OK So I finally solved it!
The epsilon only affects comparisons between variables (a == b) or a variable and a number (a == 0.5), but NOT numbers you introduce (0.4 == 0.5).

For that reason:
Code:
math_set_epsilon(0.01);

return (0.0001 == 0.0002);
This would return FALSE.

But
Code:
math_set_epsilon(0.01);

var a = 0.0001;
return (a == 0.0002);
This would return TRUE

And
Code:
math_set_epsilon(0.01);

var a = 0.0001;
var b = 0.0002
return (a == b);
This would return TRUE

more info in docs https://docs.yoyogames.com/source/d...s/real valued functions/math_set_epsilon.html
 
Top