安卓log.e函数打印示例_log1p()函数以及C ++中的示例
安卓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.0fFunction call:log1p(x);Output:0.693147C ++代碼演示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.62104Reference: C++ log1p() function
參考: C ++ log1p()函數
翻譯自: https://www.includehelp.com/cpp-tutorial/log1p-function-with-example.aspx
安卓log.e函數打印示例
總結
以上是生活随笔為你收集整理的安卓log.e函数打印示例_log1p()函数以及C ++中的示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 反恐特战队之猎影剧情介绍
- 下一篇: 模拟退火算法解决np_P和NP问题与解决