2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
#if (!defined AI_QNAN_H_INCLUDED)
|
|
|
|
#define AI_QNAN_H_INCLUDED
|
|
|
|
|
2008-09-11 20:50:15 +00:00
|
|
|
|
2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
inline bool is_qnan(const float in)
|
|
|
|
{
|
|
|
|
// _isnan() takes a double as argument and would
|
|
|
|
// require a cast. Therefore we must do it on our own ...
|
|
|
|
// Another method would be to check whether in != in.
|
|
|
|
// This should also wor since nan compares to inequal,
|
|
|
|
// even when compared with itself. However, this could
|
|
|
|
// case problems with other special floats like snan or inf
|
|
|
|
union _tagFPUNION
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
int32_t i;
|
|
|
|
} FPUNION1,FPUNION2;
|
|
|
|
|
|
|
|
FPUNION1.f = in;
|
|
|
|
FPUNION2.f = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
return FPUNION1.i == FPUNION2.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_not_qnan(const float in)
|
|
|
|
{
|
|
|
|
return !is_qnan(in);
|
|
|
|
}
|
|
|
|
|
2008-09-11 20:50:15 +00:00
|
|
|
#endif // !! AI_QNAN_H_INCLUDED
|