double値が aNaNまたは の場合の動作を分離したいと思い#INFます。を検出するためにNaN、テストします
doubleVal != doubleVal
はどう#INFですか?が の場合、このテストは true になりますdoubleValか#INF?
C++11 を使用していない場合は、<boost/math/special_functions/fpclassify.hpp>代わりにが必要になり<cmath>、対応する名前空間が変更されます。
#include <cmath> // or <boost/math/special_functions/fpclassify.hpp>
// ...
if(isinf(num)){
// ...
}
There is also a header-only library present in Boost that have neat tools to deal with floating point datatypes
#include <boost/math/special_functions/fpclassify.hpp>
You get the following functions:
template <class T> bool isfinite(T z);
template <class T> bool isinf(T t);
template <class T> bool isnan(T t);
template <class T> bool isnormal(T t);