log()

Compute natural logarithms.

  #include <math.h>
  
  double log(double x);
  
  float logf(float x);
  
  long double logl(long double x);    
Parameter

x

A floating point value.

Remarks

This function returns log e x.

If x < 0, log() assigns EDOM to errno. Use fpclassify() to check the validity of the result returned by log().

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 log() Usage

#include <math.h>

#include <stdio.h>

int main(void)

{

double x = 100.0;

printf("The natural logarithm of %f is %f\n",x, log(x));

printf("The base 10 logarithm of %f is %f\n",x, log10(x));

return 0;

}

Output:

The natural logarithm of 100.000000 is 4.605170

The base 10 logarithm of 100.000000 is 2.000000.