600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > c语言 函数的参数传递示例_isunordered()函数与C ++中的示例

c语言 函数的参数传递示例_isunordered()函数与C ++中的示例

时间:2019-02-07 16:29:40

相关推荐

c语言 函数的参数传递示例_isunordered()函数与C ++中的示例

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

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

isunordered() functionis a library function ofcmathheader, 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:1Input: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 <iostream>#include <cmath>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 conditionif (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++ isunordered() function

参考: C ++ isunordered()函数

翻译自: /cpp-tutorial/isunordered-function-with-example.aspx

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。