Syntax
#include <math.h> double log(double x);Description
log calculates the natural logarithm (base e) of x.
log returns the computed value. If x is negative, log sets errno to EDOM and may return the value -HUGE_VAL. If x is zero, log returns the value -HUGE_VAL, and may set errno to ERANGE.
This example calculates the natural logarithm of 1000.0.
#include <math.h>
int main(void)
{
double x = 1000.0,y;
y = log(x);
printf("The natural logarithm of %lf is %lf\n", x, y);
return 0;
/****************************************************************************
The output should be:
The natural logarithm of 1000.000000 is 6.907755
****************************************************************************/
}
Related Information