博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c语言 函数的参数传递示例_isunordered()函数与C ++中的示例
阅读量:2530 次
发布时间:2019-05-11

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

c语言 函数的参数传递示例

C ++ isunordered()函数 (C++ isunordered() function)

isunordered() function is a library function of cmath header, it is used to check whether the given values are unordered (if one or both values are Not-A-Number (NaN)), then they are unordered values). It accepts two values (float, double or long double) and returns 1 if the given values are unordered; 0, otherwise.

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

Syntax of isunordered() function:

isunordered()函数的语法:

In C99, it has been implemented as a macro,

在C99中,它已实现为宏,

macro isunordered(x, y)

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

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

bool isunordered (float x, float y);    bool isunordered (double x, double y);    bool isunordered (long double x, long double y);

Parameter(s):

参数:

  • x, y – represent the values to be checked as unordered.

    x,y –表示要检查的值是否为无序。

Return value:

返回值:

The returns type of this function is bool, it returns 1 if one or both arguments are NaN; 0, otherwise.

该函数的返回类型为bool ,如果一个或两个参数均为NaN,则返回1;否则返回0。 0,否则。

Example:

例:

Input:    float x = sqrt(-1.0f);    float y = 10.0f;        Function call:    isunordered(x, y);        Output:    1    Input:    float x = 1.0f;    float y = 10.0f;    Function call:    isunordered(x, y);        Output:    0

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

// C++ code to demonstrate the example of// isunordered() function#include 
#include
using namespace std;int main(){
cout << "isunordered(-5.0f, -2.0f): " << isunordered(-5.0f, -2.0f) << endl; cout << "isunordered(sqrt(-1.0f), sqrt(-2.0f)): " << isunordered(sqrt(-1.0f), sqrt(-2.0f)) << endl; cout << "isunordered(10.0f, sqrt(-1.0f)): " << isunordered(10.0f, sqrt(-1.0f)) << endl; cout << "isunordered(sqrt(-1.0f), 1.0f): " << isunordered(sqrt(-1.0f), 1.0f) << endl; float x = 10.0f; float y = 5.0f; // checking using the condition if (isunordered(x, y)) {
cout << x << "," << y << " are unordered." << endl; } else {
cout << x << "," << y << " are not unordered." << endl; } x = 10.0f; y = sqrt(-1.0f); if (isunordered(x, y)) {
cout << x << "," << y << " are unordered." << endl; } else {
cout << x << "," << y << " are unordered." << endl; } return 0;}

Output

输出量

isunordered(-5.0f, -2.0f): 0isunordered(sqrt(-1.0f), sqrt(-2.0f)): 1isunordered(10.0f, sqrt(-1.0f)): 1isunordered(sqrt(-1.0f), 1.0f): 110,5 are not unordered.10,-nan are unordered.

Reference:

参考:

翻译自:

c语言 函数的参数传递示例

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

你可能感兴趣的文章
JavaBean规范
查看>>
第四阶段 15_Linux tomcat安装与配置
查看>>
NAS 创建大文件
查看>>
学习笔记-模块之xml文件处理
查看>>
接口测试用例
查看>>
面试:用 Java 实现一个 Singleton 模式
查看>>
Sybase IQ导出文件的几种方式
查看>>
案例:手动输入一个字符串,打散放进一个列表,小写字母反序 大写字母保持不变...
查看>>
linux 系统下 tar 的压缩与解压缩命令
查看>>
阿里负载均衡,配置中间证书问题(在starcom申请免费DV ssl)
查看>>
转:How to force a wordbreaker to be used in Sharepoint Search
查看>>
MySQL存储过程定时任务
查看>>
Python中and(逻辑与)计算法则
查看>>
POJ 3267 The Cow Lexicon(动态规划)
查看>>
设计原理+设计模式
查看>>
音视频处理
查看>>
tomcat 7服务器跨域问题解决
查看>>
前台实现ajax 需注意的地方
查看>>
Jenkins安装配置
查看>>
个人工作总结05(第二阶段)
查看>>