log1p()

Compute base-e logarithms.

  #include <math.h>
  
  double log1p(double x);
  
  float log1pf(float x);
  
  long double log1pl(long double x);    
Parameter

x

The value being computed.

Remarks

These functions computes the base-e logarithm of x, denoted as loge(1.0 + x).

The value of x must be greater than -1. Use fpclassify() to check the validity of the result returned by log1p().

For small magnitude x, these functions are more accurate than log(x+1.0). The functions return base-e logarithm of (1 + x).

This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.

Listing: Example of log1p() Usage

#include <math.h>

#include <stdio.h>

int main(void)

{

float u = 5.0;

printf("log1p(%f) = %f\n", u, log1pf(u));

return 0;

}

Output:

log1p(5.000000) = 1.791759.