isnan函数 c语言

C ++ isnan()函数 (C++ isnan() function)

isnan() function is a library function of cmath header, it is used to check whether the given value is a NaN (Not-A-Number). It accepts a value (float, double or long double) and returns 1 if the given value is NaN; 0, otherwise.

isnan()函数cmath标头的库函数,用于检查给定的值是否为NaN(非数字)。 它接受一个值( float , double或long double ),如果给定值为NaN,则返回1;否则,返回1。 0,否则。

Syntax of isnan() function:

isnan()函数的语法:

In C99, it has been implemented as a macro,

在C99中,它已实现为宏,

    macro isnan(x)

In C++11, it has been implemented as a function,

在C ++ 11中,它已作为函数实现,

    bool isnan (float x);
bool isnan (double x);
bool isnan (long double x);

Parameter(s):

参数:

  • x – represents a value to be checked as a NaN.

    x –表示要检查为NaN的值。

Return value:

返回值:

The returns type of this function is bool, it returns 1 if the x is NaN; 0, otherwise.

该函数的返回类型为bool ,如果x为NaN,则返回1;否则,返回1。 0,否则。

Example:

例:

    Input:
float x = 0.0f/0.0f;
Function call:
isnan(x);
Output:
1
Input:
float x = sqrt(-1.0f);
Function call:
isnan(x);
Output:
1
Input:
float x = 10.0f;
Function call:
isnan(x);
Output:
0

C ++代码演示isnan()函数的示例 (C++ code to demonstrate the example of isnan() function)

// C++ code to demonstrate the example of
// isnan() function
#include <iostream>
#include <cmath>
using namespace std;
int main()
{cout << "isnan(sqrt(-10.0f)): " << isnan(sqrt(-10.0f)) << endl;
cout << "isnan(0.0f/0.0f): " << isnan(0.0f / 0.0f) << endl;
cout << "isnan(0.0f/1.0f): " << isnan(0.0f / 1.0f) << endl;
cout << "isnan(1.0f/0.0f): " << isnan(1.0f / 0.0f) << endl;
float x = sqrt(-1.0f);
// checking using the condition
if (isnan(x)) {cout << x << " is a NaN." << endl;
}
else {cout << x << " is not a NaN." << endl;
}
x = sqrt(2);
if (isnan(x)) {cout << x << " is a NaN." << endl;
}
else {cout << x << " is not a NaN." << endl;
}
return 0;
}

Output

输出量

isnan(sqrt(-10.0f)): 1
isnan(0.0f/0.0f): 1
isnan(0.0f/1.0f): 0
isnan(1.0f/0.0f): 0
-nan is a NaN.
1.41421 is not a NaN.

Reference: C++ isnan() function

参考: C ++ isnan()函数

翻译自: https://www.includehelp.com/cpp-tutorial/isnan-function-with-example.aspx

isnan函数 c语言

isnan函数 c语言_isnan()函数以及C ++中的示例相关推荐

  1. c语言得到系统的函数,c语言系统函数(C language system function).doc

    c语言系统函数(C language system function) c语言系统函数(C language system function) Mathematical function " ...

  2. arg是什么函数_C 语言编程 — 函数

    函数 函数的本质就是针对变量的操作过程,同时可能也会改变当前程序的状态.它接受多个输入值,计算并返回一个输出值. 函数大体上分为 3 类: 主函数:每个 C 程序都至少有一个 main(). 内置函数 ...

  3. c语言文件打开函数,C语言fopen函数中文件打开方式(参数值)

    满意答案 keaichengb.. 推荐于 2017.09.05 采纳率:40%    等级:12 已帮助:3704人 C语言fopen函数用于打开文件. 函数原型:FILE * fopen(cons ...

  4. java实现c语言的函数_C语言tolower函数介绍、示例和实现

    C语言tolower函数用于把大写字母转换为小写字母. 在本文中,我们先来介绍tolower函数的使用方法,然后编写一个自定义的_tolower函数,实现与tolower函数相同的功能. 1.包含头文 ...

  5. c语言里的fun是什么函数,c语言fun函数有什么作用

    c语言fun函数的作用是被主函数所调用,来定义一个函数或方法,这样在引用时可以用fun表示,比如[int fun(int x,int y)]. c语言fun函数的作用是: C语言中,fun函数通常被主 ...

  6. c语言timer linux 回调函数_C语言回调函数详解

    1. 什么是回调函数? 回调函数,光听名字就比普通函数要高大上一些,那到底什么是回调函数呢?恕我读得书少,没有在那本书上看到关于回调函数的定义.我在百度上搜了一下,发现众说纷纭,有很大一部分都是使用类 ...

  7. c语言函数指针封装函数,C语言之函数指针、回调函数的使用

    一.背景 首先看下如下代码,这个定义是放在头文件的,在程序中tCdrvCallbackFkt也定义了另一个变量,而且括号后面还跟定义了几个变量,不理解这个定义. typedef void (PUBLI ...

  8. c语言字体移动函数,C语言字符函数、内存函数功能及实现代码

    C语言字符函数.内存函数 功能及实现 strlen函数(求字符串长度)注意点模拟实现 strcpy函数(字符串拷贝函数)注意点模拟实现 strcat函数(字符串衔接函数)注意点模拟实现 strcmp函 ...

  9. c语言strchr函数内容,c strchr函数_c语言strchr函数_strchr函数用法

    各位看官们,大家好,上一回中咱们说的是字符串比较的例子,这一回咱们说的例子是:字符串查找.闲话休提,言归正转.让我们一起talk C栗子吧! 看官们,在C语言的标准库中为我们提供了字符串查找函数,我们 ...

最新文章

  1. 转:Git_Windows 系统下Git安装图解
  2. Leetcode 436.寻找右区间
  3. obs virtual camera
  4. phpquery类php,一个基于phpQuery的php通用采集类分享
  5. 3 useReducer及其实现
  6. Android AsyncTask异步线程
  7. 动态规划--凑硬币问题
  8. W3CSchool离线手册文档
  9. 神经网络学习小记录59——Pytorch搭建常见分类网络平台(VGG16、MobileNetV2、ResNet50)
  10. 计算机控制系统——导论
  11. 微信小程序实现OCR扫描识别
  12. Nessus安裝教程
  13. uniapp结合萤石视频ezuikit.js的爬坑记录
  14. 使用ASProfile分析可变剪切事件
  15. 有点儿累了,最近特别能吃
  16. LeetCode_二分图_中等_785. 判断二分图
  17. cb32a_c++_STL_算法_查找算法_(5)adjacent_find
  18. 拓端tecdat|R语言向量误差修正模型 (VECMs)分析长期利率和通胀率影响关系
  19. 如何在centos7上安装桌面系统
  20. win7无线局域网_FAST 讯捷路由器的无线应用

热门文章

  1. 奈飞财报不及预期,盘后重挫7%
  2. oracle 9i闪回schema,oracle 9i 闪回
  3. 不识庐山真面目 身在千山万壑中——初识可转债
  4. 【论文学习】行人检测——CVPR:通过MIMS在低分辨率图像中做行人检测
  5. 小型新闻爬虫查询网站
  6. 2022CUST程序设计天梯赛校赛L1题解
  7. 相空间重构与几个常用非线性模型实现
  8. 【Fink专题】基于Flink1.12的一些知识点分享-第二篇
  9. RPKM FPKM TPM RSEM
  10. PS中选中图层以及查看单个图层的方法