This is usable in any script. It checks to see if the two values differ by a very small value
Alt text: Code that says print(is_equal_approx(1, 0.99999999999)) and then the console log which has printed out true.
This is usable in any script. It checks to see if the two values differ by a very small value
Alt text: Code that says print(is_equal_approx(1, 0.99999999999)) and then the console log which has printed out true.
I’m guessing that if someone needs to define tolerance on such a small scale, they probably weren’t going to depend on an “approximately equal” function in the first place.
Then again, if someone has been dealing with these sorts of comparisons for a while, they’d have their own way of achieving this, so I guess it can be a handy tool for people who are just getting into game development.