isfinite函数_isfinite()函数以及C ++中的示例
isfinite函数
C ++ isfinite()函数 (C++ isfinite() function)
isfinite() function is a library function of cmath header, it is used to check whether the given value is a finite value or not? It accepts a value (float, double or long double) and returns 1 if the value is finite; 0, otherwise.
isfinite()函数是cmath标头的库函数,用于检查给定值是否为有限值? 它接受一个值( float , double或long double ),如果该值是有限的,则返回1;否则,返回1。 0,否则。
Syntax of isfinite() function:
isfinite()函数的语法:
In C99, it has been implemented as a macro,
在C99中,它已实现为宏,
macro isfinite(x)
In C++11, it has been implemented as a function,
在C ++ 11中,它已作为函数实现,
bool isfinite (float x);
bool isfinite (double x);
bool isfinite (long double x);
Parameter(s):
参数:
x – represents a value to be checked as finite value.
x –表示要检查为有限值的值。
Return value:
返回值:
The returns type of this function is bool, it returns 1 if x is a finite value; 0, otherwise.
该函数的返回类型为bool ,如果x为有限值,则返回1;否则,返回1。 0,否则。
Example:
例:
Input:
float x = 10.0f;
Function call:
isfinite(x);
Output:
1
C ++代码演示isfinite()函数的示例 (C++ code to demonstrate the example of isfinite() function)
// C++ code to demonstrate the example of
// isfinite() function
#include <iostream>
#include <cmath>
using namespace std;
int main()
{cout << "isfinite(0.0): " << isfinite(0.0) << endl;
cout << "isfinite(0.0/0.0): " << isfinite(0.0 / 0.0) << endl;
cout << "isfinite(0.0/1.0): " << isfinite(0.0 / 1.0) << endl;
cout << "isfinite(1.0/0.0): " << isfinite(1.0 / 0.0) << endl;
float x = 10.0f;
// checking finite value using the condition
if (isfinite(x)) {cout << x << " is a finite value." << endl;
}
else {cout << x << " is not a finite value." << endl;
}
x = 10.0f / 0.0f;
if (isfinite(x)) {cout << x << " is a finite value." << endl;
}
else {cout << x << " is not a finite value." << endl;
}
return 0;
}
Output
输出量
isfinite(0.0): 1
isfinite(0.0/0.0): 0
isfinite(0.0/1.0): 1
isfinite(1.0/0.0): 0
10 is a finite value.
inf is not a finite value.
Reference: C++ isfinite() function
参考: C ++ isfinite()函数
翻译自: https://www.includehelp.com/cpp-tutorial/isfinite-function-with-example.aspx
isfinite函数
isfinite函数_isfinite()函数以及C ++中的示例相关推荐
- java函数参数使用冒号_java8中:: 用法示例(JDK8双冒号用法)
JDK8中有双冒号的用法,就是把方法当做参数传到stream内部,使stream的每个元素都传入到该方法里面执行一下. 代码其实很简单: 以前的代码一般是如此的: public class Accep ...
- stl vector 函数_vector :: clear()函数,以及C ++ STL中的示例
stl vector 函数 C ++ vector :: clear()函数 (C++ vector::clear() function) vector::clear() is a library f ...
- stl vector 函数_vector :: push_back()函数,以及C ++ STL中的示例
stl vector 函数 C ++ vector :: push_back()函数 (C++ vector::push_back() function) vector::push_back() is ...
- c语言中vector函数大全,vector :: empty()函数,以及C ++ STL中的示例
C ++ vector :: empty()函数 矢量::空()是一个库函数"载体"头,它是用来检查给定的矢量是否是一个空的载体或没有,它返回一个真,如果矢量大小为0,否则返回假. ...
- stl vector 函数_vector :: crbegin()函数,以及C ++ STL中的示例
stl vector 函数 C ++ vector :: crbegin()函数 (C++ vector::crbegin() function) vector::crbegin() is a lib ...
- main函数参数,在VS中向命令行添加参数的方法
问题描述 使用main函数的参数,实现一个整数计算器,程序可以接受三个参数,第一个参数"-a"选项执行加法,"-s"选项执行减法,"-m"选 ...
- 函数指针--Nginx和Redis中两种回调函数写法
1.Nginx和Redis中两种回调函数写法 #include <stdio.h>//仿Nginx风格 //结构外声明函数指针类型 typedef void (*ngx_connectio ...
- ACMNO.40 C语言-子串 有一字符串,包含n个字符。写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串
题目描述 有一字符串,包含n个字符. 写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串. 输入 数字n 一行字符串 数字m 输出 从m开始的子串 样例输入 6 abcdef 3 样 ...
- R语言使用basename函数获取数据链接地址中的文件名称(removes all of the path up to and including the last path separator )
R语言使用basename函数获取数据链接地址中的文件名称(removes all of the path up to and including the last path separator (i ...
- pandas使用iteritems函数迭代地查看dataframe中的每个数据列(iterate over each column of a dataframe)
pandas使用iteritems函数迭代地查看dataframe中的每个数据列(iterate over each column of a dataframe) 目录 pandas使用iterite ...
最新文章
- 生命天书”破译20年,生命科学由此走向“大数据时代”
- python打印表格_使用 Python 打印漂亮的表格,这两项基本功你可会?
- mongodb 备份压缩_MongoDB 如何实现备份压缩
- 行业「趋轻」,尚美“共创品牌”推动酒店业进入春天
- 对dropout的理解详细版
- 每日一天:对象数组去重
- 力登:以智能化管理提升数据中心服务能力成熟度
- 知道世界越大,就会觉得你越小
- 编译器GCC的Windows版本 : MinGW-w64安装教程
- 基于STM32设计的NB-IOT电量采集系统(超级详细)--1.Onenet平台配置及M5311配置
- 程序员做自媒体,龙叔教你怎么快速成为优秀博主【CSDN篇】
- 【Latex】一、TeX Live和TeXstudio安装及使用教程
- idea clean Process terminated
- 2021执念斩长河年度总结
- 递归来实现一个二分查找算法函数bi_search()
- 中国科学院计算机博士范,范可(中科院研究员)_百度百科
- 浏览器内核、webview内核
- 全面质量管理理论中的五个影响产品质量的主要因素
- element-ui的走马灯详解
- python实现图片拼接(项目界面展示图合并)