Topic was automatically imported from the old Question2Answer platform.

Asked By

Matt101

Can someone explain to me how the is_equal_approx method works? I’ve read the documents, but I couldn’t quite understand how it works, especially regarding the function parameters.

It turns out that most fractional decimals cannot be represented precisely in binary and so there are a lot of fractional decimals which are approximated when stored in the computer causing what is known as floating point imprecision

An epsilon (Greek Letter) is used by is_equal_approx to determine if two floating points shall be considered equal or not and the function name is self explanatory hence the vague documentation.

Example

is_equal_approx(1.39999, 1.4) # yes it is

Same should apply for Rects, Basis, Vectors, Transforms

The numbers in your example have too great of a difference. Also, there should be no capitalization (at least for engine version 3.5). Here:

is_equal_approx(1.399999999, 1.4) # yes it is

Now the difference should be less than epsilon, making the numbers “approximately equal”.