log1p
返回以e为底1+x的对数函数值,即计算ln(1+x)的值。
接口定义
C interface:
float log1pf(float x);
double log1p(double x);
long double log1pl(long double x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 返回以e为底1+x的对数函数值y,y ∈ (-INF, +INF)。
- 输入x为+0,返回+0。
- 输入x为-0,返回-0。
- 输入x为-1,返回-∞。
- 输入x为+∞,返回+∞。
- 输入x<-1,返回nan。
- 输入x为nan,返回nan。
依赖
C: "km.h"
示例
C interface:
// typical usage double x1 = 0.0, x2 = -0.0, x3 = -1, x4 = -2; // special handing double a = INFINITY, b = -INFINITY, c = NAN; // print result printf("log1p(0.0) = %.15f\n", log1p(x1)); printf("log1p(-0.0) = %.15f\n", log1p(x2)); printf("log1p(-1) = %.15f\n", log1p(x3)); printf("log1p(-2) = %.15f\n", log1p(x4)); printf("log1p(INFINITY) = %.15f\n", log1p(a)); printf("log1p(-INFINITY) = %.15f\n", log1p(b)); printf("log1p(NAN) = %.15f\n", log1p(c)); /* * log1p(0.0) = 0.000000000000000 * log1p(-0.0) = -0.000000000000000 * log1p(-1) = -inf * log1p(-2) = nan * log1p(INFINITY) = inf * log1p(-INFINITY) = nan * log1p(NAN) = nan * * */
父主题: 指数和对数函数