0 votes

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

Godot version v. 3.3.2
in Engine by (39 points)

2 Answers

+1 vote
Best answer

Floating Point Imprecision

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

How then do you decide that two floating points shall be considered equal?
That's called an epsilon (Greek Letter) which is used by Is_equal_approx and the function name is self explanatory hence the vague documentation.

Is_equal_approx(1.333333333, 1.4) # yes it is

Same should apply for Rects, Basis, Vectors, Transforms

by (4,560 points)
selected by
+1 vote

Hi
the function will return true when a and b are equal or only have a very slight deviation.

The tolerance scales with size of the numbers. Higher numbers are treated with a higher tolerance when compared.

by (3,932 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.