<cmath>
in C++11
supports std::isan()
.
Returns true
if the factor is NaN
, or false
if not.
bool isnan( float arg ); (since C++11)
bool isnan( double arg ); (since C++11)
bool isnan( long double arg ); (since C++11)
According to IEEE standard
,
NaN value
is always false
when comparing NaN value
.
This means that f!=f
is always true
for float/doublef
.
In principle, this method should work for a compiler that follows IEEE floating point
I'm not sure that optimization is followed.
It is recommended that you check and write in advance with the compiler.
© 2024 OneMinuteCode. All rights reserved.