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 <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 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): 0
isunordered(sqrt(-1.0f), sqrt(-2.0f)): 1
isunordered(10.0f, sqrt(-1.0f)): 1
isunordered(sqrt(-1.0f), 1.0f): 1
10,5 are not unordered.
10,-nan are unordered.
Reference: C++ isunordered() function
参考: C ++ isunordered()函数
翻译自: https://www.includehelp.com/cpp-tutorial/isunordered-function-with-example.aspx
c语言 函数的参数传递示例