安卓log.e函数打印示例
C ++ log2()函数 (C++ log2() function)
log2() function is a library function of cmath header, it is used to get the binary logarithm (the base-2 logarithm) of the given value. It accepts a value (float, double, or long double) and returns the binary logarithm.
log2()函数是cmath标头的库函数,用于获取给定值的二进制对数(以2为底的对数)。 它接受一个值( float , double或long double )并返回二进制对数。
Syntax of log2() function:
log2()函数的语法:
C++11:
C ++ 11:
double log2 (double x);
float log2 (float x);
long double log2 (long double x);
double log2 (T x);
Parameter(s):
参数:
x – represents the value whose binary logarithm to be found.
x –表示要找到其二进制对数的值。
Return value:
返回值:
It returns the binary logarithm of the given value x.
它返回给定值x的二进制对数。
Note:
注意:
If the given value is negative, it causes a domain error.
如果给定值为负,则将导致域错误。
If the given value is zero, it may cause a pole error.
如果给定值为零,则可能导致极点错误。
Example:
例:
Input:
float x = 2.0f
Function call:
log2(x);
Output:
1
C ++代码演示log2()函数的示例 (C++ code to demonstrate the example of log2() function)
// C++ code to demonstrate the example of
// log2() function
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float x = 0.0f;
x = 10.0f;
cout << "log2(" << x << "): " << log2(x) << endl;
x = 2.0f;
cout << "log2(" << x << "): " << log2(x) << endl;
x = 20.0f;
cout << "log2(" << x << "): " << log2(x) << endl;
x = -10.4f;
cout << "log2(" << x << "): " << log2(x) << endl;
x = 0.0f;
cout << "log2(" << x << "): " << log2(x) << endl;
x = 100.6f;
cout << "log2(" << x << "): " << log2(x) << endl;
return 0;
}
Output
输出量
log2(10): 3.32193
log2(2): 1
log2(20): 4.32193
log2(-10.4): nan
log2(0): -inf
log2(100.6): 6.65249
Reference: C++ log2() function
参考: C ++ log2()函数
翻译自: https://www.includehelp.com/cpp-tutorial/log2-function-with-example.aspx
安卓log.e函数打印示例