Hi I have a function that is giving me odd behvior only on release 64 bit release builds. 32bit works in all cases and 64bit works in debug. Anyway heres the original code, the value of value is a real number like 5 or 100 etc.:
static void
Foo(char **pInOut, unsigned int key, double value)
{
if (value == -HUGE_VAL)
return;
if (value != value)
return;
// Does stuff that isn't happening
}
I was playing around and I replaced the value != value with:
static void
Foo(char **pInOut, unsigned int key, double value)
{
if (value == -HUGE_VAL)
return;
if (_isnan(value))
return;
// Does stuff that happens now
}
Now it’s working. value != value is still valid right? am I missing something…i just dont see why the old way wouldn’t work?
If it’s a NaN, then
value!=valuewill be true. But if it’s not a NaN, it’s not guaranteed thatvalue!=valuewill be false.