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]
corrupt float
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.
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); }
bool IsNum(float f) { return (f == f); }
NaN means "Not a Number"
for the rest look there
http://www.psc.edu/general/software/packages/ieee/ieee.html
greets Tgar
for the rest look there
http://www.psc.edu/general/software/packages/ieee/ieee.html
greets Tgar
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?
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?
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".
Quote:Original post by xdotdt
is there a version for float?
they work just as good with floats
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement