安卓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.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函数打印示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值