_isinf, _isinfl:判断浮点数为无穷大:+∞ 或 -∞
函数原型:
int _isinf(double x); |
int _isinfl(long double x); |
头文件:
#include <cfloat>
命名空间:
std
参数:
x:浮点数,double 或 long double 类型
返回值:
≠0: 参数 x 为无穷大,即 +INF 或 -INF
=0: 参数 x 不是无穷大,可能是实数,也可能是 NAN
例子:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double z = 0.0;
double a = 1.0;
double b = -2.0;
UnicodeString s;
s.cat_sprintf(L"%4.1lf/%4.1lf = %4.1lf ; _isinf(%4.1lf) = %d\r\n", a, z, a/z, a/z, std::_isinf(a/z));
s.cat_sprintf(L"%4.1lf/%4.1lf = %4.1lf ; _isinf(%4.1lf) = %d\r\n", b, z, b/z, b/z, std::_isinf(b/z));
s.cat_sprintf(L"%4.1lf/%4.1lf = %4.1lf ; _isinf(%4.1lf) = %d\r\n", z, z, z/z, z/z, std::_isinf(z/z));
s.cat_sprintf(L"%4.1lf/%4.1lf = %4.1lf ; _isinf(%4.1lf) = %d\r\n", a, b, a/b, a/b, std::_isinf(a/b));
Memo1->Lines->Text = s;
} |
兼容性:
相关链接:
• _finite • _isinf • _isnan • _fpclass • _control87 • SetExceptionMask • _matherr • 浮点数异常处理
|