Testing for NaN

  • Thread starter Thread starter Rudy Ray Moore
  • Start date Start date
R

Rudy Ray Moore

How do I test a float for NaN (or other weird garbage) without messing up my
FPU or throwing exceptions or other bizarro things?

I'm using VS6

Thanks,

Rudy

===

float f;

SetFloatToFunnyValue(&f);

if( IsFunnyValue(f) )
{
f = 0.0f;
}
 
See _isnan() in the VC++ documentation. It's delcared in <float.h>

-cd
 
Rudy said:
How do I test a float for NaN (or other weird garbage) without messing up my
FPU or throwing exceptions or other bizarro things?

I'm using VS6

Thanks,

Rudy

===

float f;

SetFloatToFunnyValue(&f);

if( IsFunnyValue(f) )
{
f = 0.0f;
}

_finite()
_isnan()
_fpclass()

Google around for IEEE 754 will get some interesting links if you want
to do stuff manually with some lower level code (bitwise integer
operations, or asm or something)

http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top