🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

is float compare bitwise?

Started by
3 comments, last by WitchLord 10 years, 5 months ago

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.

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.

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).

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).

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement