c语言 函数的参数传递示例
C ++ signbit()函数 (C++ signbit() function)
signbit() function is a library function of cmath header. It is used to check the sign of the given value. It accepts a parameter (float, double or long double) and returns 1 if the given value is negative; 0, otherwise.
signbit()函数是cmath标头的库函数。 用于检查给定值的符号。 它接受一个参数( float , double或long double ),如果给定的值为负,则返回1;否则返回1 。 0 ,否则。
Syntax of signbit() function:
signbit()函数的语法:
In C99, it has been implemented as a macro,
在C99中,它已实现为宏,
signbit(x)
In C++11, it has been implemented as a function,
在C ++ 11中,它已作为函数实现,
bool signbit (float x);
bool signbit (double x);
bool signbit (long double x);
Parameter(s):
参数:
x – represents the value to check its sign.
x –表示检查其符号的值。
Return value:
返回值:
It returns 1 if x is negative; 0, otherwise.
如果x为负,则返回1;否则为0。 0,否则。
Example:
例:
Input:
double x = 10.0;
Function call:
signbit(x);
Output:
0
Input:
double x = -10.0;
Function call:
signbit(x);
Output:
1
C ++代码演示signbit()函数的示例 (C++ code to demonstrate the example of signbit() function)
// C++ code to demonstrate the example of
// signbit() function
#include <iostream>
#include <cmath>
using namespace std;
// main() section
int main()
{
double x = 0.0;
x = 10.0;
cout << "signbit(" << x << "): " << signbit(x) << endl;
x = -10.0;
cout << "signbit(" << x << "): " << signbit(x) << endl;
x = 10.10;
cout << "signbit(" << x << "): " << signbit(x) << endl;
x = -10.10;
cout << "signbit(" << x << "): " << signbit(x) << endl;
x = 0.0;
cout << "signbit(" << x << "): " << signbit(x) << endl;
x = -10.0 / 2.5;
cout << "signbit(" << x << "): " << signbit(x) << endl;
x = 10.0 / -2.5;
cout << "signbit(" << x << "): " << signbit(x) << endl;
x = sqrt(-1);
cout << "signbit(" << x << "): " << signbit(x) << endl;
return 0;
}
Output
输出量
signbit(10): 0
signbit(-10): 1
signbit(10.1): 0
signbit(-10.1): 1
signbit(0): 0
signbit(-4): 1
signbit(-4): 1
signbit(-nan): 1
Reference: C++ signbit() function
参考: C ++ signbit()函数
翻译自: https://www.includehelp.com/cpp-tutorial/signbit-function-with-example.aspx
c语言 函数的参数传递示例