c语言 函数的参数传递示例_isunordered()函数与C ++中的示例
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:1Input:float x = 1.0f;float y = 10.0f;Function call:isunordered(x, y);Output:0C ++代碼演示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): 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語言 函數的參數傳遞示例
總結
以上是生活随笔為你收集整理的c语言 函数的参数传递示例_isunordered()函数与C ++中的示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: javascript模块_JavaScr
- 下一篇: 计算机中央处理器cpu_中央处理器(CP