2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
#if (!defined AI_QNAN_H_INCLUDED)
|
|
|
|
#define AI_QNAN_H_INCLUDED
|
|
|
|
|
2009-01-15 19:22:29 +00:00
|
|
|
// Data structure for a 32 Bit IEEE 754 floating-point number
|
|
|
|
union _IEEESingle
|
|
|
|
{
|
|
|
|
float Float;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t Frac : 23;
|
|
|
|
uint32_t Exp : 8;
|
|
|
|
uint32_t Sign : 1;
|
|
|
|
} IEEE;
|
|
|
|
} ;
|
2008-09-11 20:50:15 +00:00
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// check whether a float is NaN
|
|
|
|
AI_FORCE_INLINE bool is_qnan(float in)
|
2008-06-22 10:09:26 +00:00
|
|
|
{
|
2008-10-13 16:45:48 +00:00
|
|
|
return (in != in);
|
|
|
|
}
|
2008-06-22 10:09:26 +00:00
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// check whether a float is NOT NaN.
|
|
|
|
AI_FORCE_INLINE bool is_not_qnan(float in)
|
|
|
|
{
|
|
|
|
return (in == in);
|
2008-06-22 10:09:26 +00:00
|
|
|
}
|
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// check whether a float is either NaN or (+/-) INF. Denorms return false,
|
|
|
|
// they're treated like normal values.
|
|
|
|
AI_FORCE_INLINE bool is_special_float(float in)
|
2008-06-22 10:09:26 +00:00
|
|
|
{
|
2009-01-15 19:22:29 +00:00
|
|
|
return (((_IEEESingle*)&in)->IEEE.Exp == (1u << 8)-1);
|
2008-06-22 10:09:26 +00:00
|
|
|
}
|
|
|
|
|
2008-09-11 20:50:15 +00:00
|
|
|
#endif // !! AI_QNAN_H_INCLUDED
|