主页C++ Builder 资料C++ Builder 参考手册cfloat 浮点数_isnan, _isnanl
C++ Builder 串口控件
C++ Builder 编程技巧
C++ Builder 操作指南
C++ Builder 参考手册
基础知识
cfloat 浮点数
 • 浮点数类型
 • 浮点数异常处理
 • _finite, _finitel
 • _isinf, _isinfl
 • _isnan, _isnanl
 • _fpclass, _fpclassl
 • _chgsign, _chgsignl
 • _copysign, _copysignl
 • _logb, _logbl
 • _scalb, _scalbl
 • _nextafter, _nextafterl
 • _clear87, _clearfp
 • _control87, _controlfp
 • _status87, _statusfp
 • _fpreset
cmath 数学函数
cstdlib 标准库函数
System 字符串
System 日期和时间
System.Math.hpp 数学函数
其他数据类型
VCL 基础类
VCL 应用程序
Pictures 图片
Graphics 绘图
Additional 控件
System 控件
A ~ Z 字母顺序排列的目录
网友留言/技术支持
_isnan, _isnanl - 判断浮点数为 NAN (不是数,Not a Number)

_isnan, _isnanl:判断浮点数为 NAN (不是数,Not a Number)

函数原型:

int _isnan(double x);
int _isnanl(long double x);

头文件:

#include <cfloat>

命名空间:

std

参数:

x:浮点数

返回值:

≠0: 参数 x 是 NAN
=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 ; _isnan(%4.1lf) = %d\r\n", a, z, a/z, a/z, std::_isnan(a/z));
  s.cat_sprintf(L"%4.1lf/%4.1lf = %4.1lf ; _isnan(%4.1lf) = %d\r\n", b, z, b/z, b/z, std::_isnan(b/z));
  s.cat_sprintf(L"%4.1lf/%4.1lf = %4.1lf ; _isnan(%4.1lf) = %d\r\n", z, z, z/z, z/z, std::_isnan(z/z));
  s.cat_sprintf(L"%4.1lf/%4.1lf = %4.1lf ; _isnan(%4.1lf) = %d\r\n", a, b, a/b, a/b, std::_isnan(a/b));
  Memo1->Lines->Text = s;
}

兼容性:

函数 \ C++ Builder 编译器 bcc32 clang32 clang64
_isnan
_isnanl

相关链接:

_finite_isinf_isnan_fpclass_control87SetExceptionMask_matherr浮点数异常处理

◤上一页:_isinf, _isinfl下一页:_fpclass, _fpclassl

C++ 爱好者 -- Victor Chen 的个人网站 www.cppfans.com 辽ICP备11016859号