我正在使用 Visual Studio Express 2013 构建 C++ 库。我想调用 the isnormal
function来自 cmath
,但 VS 库似乎只有 _isnan
和 _finite
(它们在 cfloat
中,不是 cmath
)。
它还提供了 _fpclass
,我假设它对应于 fpclassify
.以下宏是否适合替代 isnormal
?
#ifdef _WIN32
#define isnormal(x) (_fpclass(x) == _FPCLASS_NN || _fpclass(x) == _FPCLASS_PN)
#endif
最佳答案
根据 this blog post isnormal
至少出现在 MSVC2013 的 <math.h>
中.因此,在 <cmath>
你应该找到对应的std::isnormal
(您记得使用命名空间 std,对吧?)。否则,您将不得不回退到 C header 。
(或者可能修复/更新您的 MSVC 安装 - MGetz 的评论显示他的 VS2013 Express 安装有 std::isnormal
)
关于c++ - Visual Studio 是否提供 C 库的 isnormal()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23112779/