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函数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/378252.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

android 服务端 漏洞,安卓漏洞 CVE 2017-13287 复现详解-

2018年4月&#xff0c;Android安全公告公布了CVE-2017-13287漏洞。与同期披露的其他漏洞一起&#xff0c;同属于框架中Parcelable对象的写入(序列化)与读出(反序列化)的不一致所造成的漏洞。在刚看到谷歌对于漏洞给出的补丁时一头雾水&#xff0c;在这里要感谢heeeeenMS509Team…

某公司面试题

一、基础题 1&#xff0c;冯诺依曼结构的计算机硬件逻辑组成中&#xff0c;不包含以下哪个模块&#xff1f; A&#xff0c;编译器 B&#xff0c;控制器 C&#xff0c;输入设备 D&#xff0c;输出设备 解释&#xff1a;冯诺依曼由五个模块组成&#xff1a;输入设备 输出设备 存…

GAP(全局平均池化层)操作

转载的文章链接&#xff1a; 为什么使用全局平均池化层&#xff1f; 关于 global average pooling https://blog.csdn.net/qq_23304241/article/details/80292859 在卷积神经网络的初期&#xff0c;卷积层通过池化层&#xff08;一般是 最大池化&#xff09;后总是要一个或n个全…

zoj1245 Triangles(DP)

/* 动态三角形&#xff1a;每次DP时考虑的是两个子三角形的高度即可 注意&#xff1a; 三角形可以是倒置的。 */ View Code 1 #include <iostream> 2 #include <cstdlib> 3 #include <cstring> 4 #include <stdio.h> 5 6 using namespace std; 7 8…

第十八章 程序打包

第十八章 程序打包 Setuptools和较旧的Distutils都是用于发布Python包的工具包&#xff0c;能够使用Python轻松地编写安装脚本。这些脚本可用于生成可发布的归档文档&#xff0c;供用户用来编译和安装编写库。 Setuptools并非只能用于创建基于脚本的Python安装程序&#xff0…

如何在Java中检查对象是否为空?

With the help of "" operator is useful for reference comparison and it compares two objects. 借助“ ”运算符&#xff0c;对于参考比较非常有用&#xff0c;它可以比较两个对象。 "" operator returns true if both references (objects) points to…

android编程从零开始,从零开始学习android开发

博主最近开通了Android栏目&#xff0c;现在正在从零开始学习android&#xff0c;遇到的所有值得分享的知识点以及遇到的问题将发布在这个博客的android栏目下。因为我有着深厚的java底子&#xff0c;所以学习起来得心应手&#xff0c;十分的简单&#xff0c;当然也只能算是入门…

CNN基本步骤以及经典卷积(LeNet、AlexNet、VGGNet、InceptionNet 和 ResNet)网络讲解以及tensorflow代码实现

课程来源&#xff1a;人工智能实践:Tensorflow笔记2 文章目录前言1、卷积神经网络的基本步骤1、卷积神经网络计算convolution2、感受野以及卷积核的选取3、全零填充Padding4、tf描述卷积层5、批标准化(BN操作)6、池化Pooling7、舍弃Dropout8、卷积神经网络搭建以及参数分析2、经…

String.valueOf()

1. 由 基本数据型态转换成 String String 类别中已经提供了将基本数据型态转换成 String 的 static 方法 也就是 String.valueOf() 这个参数多载的方法 有下列几种 String.valueOf(boolean b) : 将 boolean 变量 b 转换成字符串 String.valueOf(char c) : 将 char 变量 c 转换成…

emacs gdb 调试

写下linux下用emacs调用dgb调试的方法 emacs中使用gdb 说明C等价于ctrl M等价于alt 1,编写 .c函数 test.c 2&#xff0c;gcc一把 看看对不对 带上-g gcc -g -o test .debug test.c 如果要用gdb调试器&#xff0c;必须使用g选项。 3&#xff0c;#ema…

第十九章 趣味编程

第十九章 趣味编程 本章将介绍一些通用的Python编程指南。 为何要有趣 Python有趣的地方之一就是让用户的编程效率非常高效。 极限编程是一种软件开发方法 编程柔术 python的灵活性描述原型设计Python的优点之一是让你能够快速地编写程序。要更深入地了解面临的问题&#…

android按钮在容器下方,使用flex布局解决安卓手机上固定在底部的按钮,在键盘弹起后挡住input输入框的问题...

移动端经常会出现&#xff0c;一个表单里面&#xff0c;确定按钮固定在底部这样的布局&#xff0c;一般会让按钮absolute或者fixed&#xff0c;这样在ios上没有问题&#xff0c;但是在安卓手机上&#xff0c;当表单里面的input输入框获得焦点的时候&#xff0c;按钮会挡在表单上…

dbms支持哪几种数据模型_DBMS中不同类型的数据模型

dbms支持哪几种数据模型资料模型 (Data Model) A data model is a model that defines in which format the data are represented and accessed. Data model mainly defines some of the data elements and relationships that exist between them. 数据模型是定义数据以哪种格…

JS 数组迭代方法

var arr [3,4,5,6,7,"a"]; var isNum function(elem,index,AAA){ return !isNaN(elem);} var toUpperCase function(elem){ return String.prototype.toUpperCase.apply(elem);} var print function(elem,index){ console.log(index"."elem);} /*对数组…

php开源问答_PHP基础知识能力问答

php开源问答This section contains Aptitude Questions and Answers on PHP Basics. 本部分包含有关PHP基础知识的 Aptitude问题和解答。 1) There are the following statements that are given below, which of them are correct PHP? PHP stands for the Preprocessor Hom…

【数据结构基础笔记】【顺序表】

代码参考《妙趣横生的算法.C语言实现》 文章目录前言1、创建顺序表2、顺序表插入元素3、顺序表删除元素4、顺序表实例分析1、静态2、动态5、顺序表总结前言 本章总结&#xff1a;从静态和动态分别进行顺序表的创建、插入、删除、以及实例分析 1、创建顺序表 1、静态地生成一张…

ubuntu安装oracle unzip: No such file or directory

$ln -s /usr/bin/unzip /你的oracle11安装目录/install/unzip$sudo chmod 777 /usr/bin/unzip转载于:https://www.cnblogs.com/qm4050/archive/2011/08/25/2241466.html

一、网络爬虫概述

1&#xff0c;浏览器与网络爬虫的区别 答&#xff1a; 对于浏览器而言&#xff1a;浏览器打开一个网站&#xff0c;会对网站服务器发送一个request请求&#xff0c;服务器收到该请求之后&#xff0c;会给浏览器一个respond响应&#xff0c;该响应携带很多数据&#xff0c;之后…

百度android广告sdk下载,IS_Freedom

美数广告 SDK接入流程1.嵌入广告SDK将 sdk-android-demo/app/libs 中的 meishu-sdk_xxx_release.aar、open_ad_sdk_xxx.aar、Baidu_MobAds_SDK-release-xxx.aar、GDTSDK.unionNormal.xxx.aar、msa_mdid_1.0.13 拷贝到项目的 libs 下&#xff0c;对应的 build.gradle 文件里面添…

关于《加密与解密》的读后感----对dump脱壳的一点思考

偶然翻了一下手机日历&#xff0c;原来今天是夏至啊&#xff0c;时间过的真快。ISCC的比赛已经持续了2个多月了&#xff0c;我也跟着比赛的那些题目学了2个月.......虽然过程很辛苦&#xff0c;但感觉还是很幸运的&#xff0c;能在大三的时候遇到ISCC&#xff0c;不管怎样&…