1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 [SOLVED] math_set_epsilon() does it even work?

Discussion in 'Advanced Programming Discussion' started by Pere, Dec 9, 2018.

Tags:
  1. Pere

    Pere Member

    Joined:
    Jan 5, 2017
    Posts:
    29
    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?
     
  2. Pere

    Pere Member

    Joined:
    Jan 5, 2017
    Posts:
    29
    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice