title | ms.custom | ms.date | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | apiname | apilocation | apitype | f1_keywords | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
log1p, log1pf, log1pl2 | Microsoft Docs |
11/04/2016 |
|
article |
|
|
DLLExport |
|
|
a40d965d-b4f6-42f4-ba27-2395546f7c12 |
7 |
corob-msft |
corob |
ghogen |
Computes the natural logarithm of 1 plus the specified value.
double log1p(
double x
);
float log1p(
float x
); //C++ only
long double log1p(
long double x
); //C++ only
float log1pf(
float x
);
long double log1pl(
long double x
);
x
The floating-point argument.
If successful, returns the natural (base-e) log of (x
+1).
Otherwise, may return one of the following values:
Input | Result | SEH exception | errno |
---|---|---|---|
+inf | +inf | ||
Denormals | Same as input | UNDERFLOW | |
±0 | Same as input | ||
-1 | -inf | DIVBYZERO | ERANGE |
< -1 | nan | INVALID | EDOM |
-inf | nan | INVALID | EDOM |
±SNaN | Same as input | INVALID | |
±QNaN, indefinite | Same as input |
The errno
value is set to ERANGE if x
= -1. The errno
value is set to EDOM if x
< -1.
The log1p
functions may be more accurate than using log(x
+1) when x is near 0.
Because C++ allows overloading, you can call overloads of log1p
that take and return float and long double types. In a C program, log1p
always takes and returns a double.
If x
is a natural number, this function returns the logarithm of the factorial of (x
-1).
Function | C header | C++ header |
---|---|---|
log1p , log1pf , log1pl |
<math.h> | <cmath> |
For additional compatibility information, see Compatibility.
Alphabetical Function Reference
log2, log2f, log2l
log, logf, log10, log10f