博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
isfinite函数_isfinite()函数以及C ++中的示例
阅读量:2527 次
发布时间:2019-05-11

本文共 2077 字,大约阅读时间需要 6 分钟。

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 
#include
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): 1isfinite(0.0/0.0): 0isfinite(0.0/1.0): 1isfinite(1.0/0.0): 010 is a finite value.inf is not a finite value.

Reference:

参考:

翻译自:

isfinite函数

转载地址:http://ehxzd.baihongyu.com/

你可能感兴趣的文章
根据html页面模板动态生成html页面(c#类)
查看>>
Failed to Connect to MySQL at 127.0.0.1:3306 MySql WorkBench 本地连接问题
查看>>
android下activity中多个listview只允许主界面滚动
查看>>
(贪心5.2.1)UVA 10026 Shoemaker's Problem(利用数据有序化来进行贪心选择)
查看>>
java基础练习 4
查看>>
Swift学习:扩展(Extensions)
查看>>
java了解
查看>>
[基础] 模板+友元类外定义
查看>>
【日常训练】数据中心(CSP 201812-4)
查看>>
《JavaScript总结》apply、call和bind方法
查看>>
Alpha 冲刺 (5/10)
查看>>
递归和二分法
查看>>
vs命令行参数说明
查看>>
C++Builder调整TreeView和ListView间距
查看>>
205. Isomorphic Strings
查看>>
SynchronousQueue
查看>>
JQuery常用函数及功能小结
查看>>
POJ 2653 Pick-up sticks 线段相交
查看>>
PKU JudgeOnline 题目分类
查看>>
网站报错Access denied for user 'root'@'localhost' -问题排查续
查看>>