std::isinf
定义于头文件 <cmath>
|
||
bool isinf( float arg ); |
(1) | (C++11 起) |
bool isinf( double arg ); |
(2) | (C++11 起) |
bool isinf( long double arg ); |
(3) | (C++11 起) |
bool isinf( IntegralType arg ); |
(4) | (C++11 起) |
1-3) 确定给定浮点数
arg
是否为正或负无穷大。参数
arg | - | 浮点值 |
返回值
若 arg
为无穷大则为 true ,否则为 false 。
示例
运行此代码
#include <iostream> #include <cmath> #include <cfloat> int main() { std::cout << std::boolalpha << "isinf(NaN) = " << std::isinf(NAN) << '\n' << "isinf(Inf) = " << std::isinf(INFINITY) << '\n' << "isinf(0.0) = " << std::isinf(0.0) << '\n' << "isinf(exp(800)) = " << std::isinf(std::exp(800)) << '\n' << "isinf(DBL_MIN/2.0) = " << std::isinf(DBL_MIN/2.0) << '\n'; }
输出:
isinf(NaN) = false isinf(Inf) = true isinf(0.0) = false isinf(exp(800)) = true isinf(DBL_MIN/2.0) = false
参阅
(C++11) |
归类给定的浮点值 (函数) |
(C++11) |
检查给定数是否拥有有限值 (函数) |
(C++11) |
检查给定的数是否 NaN (函数) |
(C++11) |
检查给定数是否正规 (函数) |