• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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

P

Pere

Guest
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?
 
P

Pere

Guest
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