log1p, log1pf, log1pl

Visual Studio 2015
 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at log1p, log1pf, log1pl2.

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  
);  
  

Parameters

x
The floating-point argument.

If successful, returns the natural (base-e) log of (x+1).

Otherwise, may return one of the following values:

InputResultSEH exceptionerrno
+inf+inf
DenormalsSame as inputUNDERFLOW
±0Same as input
-1-infDIVBYZEROERANGE
< -1nanINVALIDEDOM
-infnanINVALIDEDOM
±SNaNSame as inputINVALID
±QNaN, indefiniteSame 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).

FunctionC headerC++ header
log1p, log1pf, log1pl<math.h><cmath>

For additional compatibility information, see Compatibility.

Alphabetical Function Reference
log2, log2f, log2l
log, logf, log10, log10f

Show: