Jump to content
  • Advertisement
Sign in to follow this  
xdotdt

corrupt float

This topic is 4823 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

How can I detect whether a float variable is corrupt? When I debug some codes, sometimes it happens that a float variable becomes like 1.#QNAN0, or similar forms. How can I know this in code, not in debugging-mode by doing like below.
if( corrupt( float_var ) )
{
    printf( "corrupt" );
}
And someone knows what that means? I mean what 1.#QNAN0 or similar one means? [Edited by - xdotdt on July 11, 2005 1:08:04 AM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
All NaN values have the property that any comparison operations (, >=, !=,==) are false: so it is not equal to itself.

bool IsNum(float f) { return (f == f); }

Share this post


Link to post
Share on other sites
NaN means "Not a Number"

for the rest look there
http://www.psc.edu/general/software/packages/ieee/ieee.html

greets Tgar

Share this post


Link to post
Share on other sites
thanks glSmurf.
I found a similar function.

_CRTIMP int __cdecl _finite(double);
_CRTIMP int __cdecl _isnan(double);

Are _finite() and _isnan() different?
If so, how are they different?

Plus, is there a version for float?

Share this post


Link to post
Share on other sites
Quote:
Original post by xdotdt
thanks glSmurf.
I found a similar function.

_CRTIMP int __cdecl _finite(double);
_CRTIMP int __cdecl _isnan(double);

Are _finite() and _isnan() different?
If so, how are they different?

They are different in how they treat infinity.

finite returns true for normal numbers, and false for Inf (Infnity) and NaN (Not a Number). isnan returns true for NaN, and false for Inf and normal numbers. It's just a matter of whether Inf is "treated" as a number or a NaN, so to speak. As there are three "states"; number, Inf and NaN, a single true/false function is not enough to identity the different "states".

Share this post


Link to post
Share on other sites
Quote:
Original post by xdotdt
is there a version for float?


they work just as good with floats

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!