Advertisement Jump to content
Sign in to follow this  
iraxef

is float compare bitwise?

This topic is 1826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The documentation says:

 

 

 

The operators == and != are used to compare two values to determine if they are equal or not equal, respectively. The result of this operation is always a boolean value.

 

Am I right in assuming that this is a bitwise compare for two floats?

 

Thank you.

Share this post


Link to post
Share on other sites
Advertisement
I haven't used Angelscript, but it probably uses the default float comparison method (processor instruction), which is not bitwise. NaN should not equal NaN. If it is, then it's bitwise. Edited by Nypyren

Share this post


Link to post
Share on other sites

I suppose I was asking whether I should bind the float-comparison functionality that I have available in C++.

 

Sort of like an epsilon (vs bitwise) compare (though I use a relative, not an absolute compare).

Share this post


Link to post
Share on other sites

I'd not override a defined and well known behavior. Using a function like closeTo(a, b, epsilon) clearly expresses what happens, especially w.r.t. the fact that a 3rd argument is involved (although there may be a default for it).

Share this post


Link to post
Share on other sites

The equality operator in AngelScript doesn't perform an approximate comparison of floats. It does not do a bitwise comparison though, for the same reason that Nypyren mentioned.

 

I recommend going with haegarr's suggestion and register an explicit function for doing approximate comparison of floats/doubles.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!