Actually you have an easier way to achieve this in C++. From the C++ standard 18.2.1.1
the class numeric_limits
exists within std
. In order to access said static member you simply do this:
std::numeric_limits<double>::is_iec559;
Or:
std::numeric_limits<float>::is_iec559;
Which should return true
if IEEE 754 is in use, false otherwise.
As an alternative method, the second part of Adam's answer should do it also for C++.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…