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