Format
#include <math.h>
double log(double x);
Language Level: ANSI
Threadsafe: Yes.
Description
The log() function calculates the natural logarithm (base e) of x.
Return Value
The log() function returns the computed value. If x is negative, log()sets errno to EDOM and might return the value -HUGE_VAL. If x is zero, log() returns the value -HUGE_VAL, and might set errno to ERANGE.
Example that uses log()
This example calculates the natural logarithm of 1000.0.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x = 1000.0, y;
y = log(x);
printf("The natural logarithm of %lf is %lf\n", x, y);
}
/******************** Output should be similar to: **************
The natural logarithm of 1000.000000 is 6.907755
*/
Related Information