log

compute the natural logarithm of a number

Synopsis:

#include <math.h>
double log( double x );

Description:

The log() function computes the natural logarithm (base e) of x. A domain error occurs if the argument is negative. A range error occurs if the argument is zero.

Returns:

The log() function returns the natural logarithm of the argument.

When the argument is outside the permissible range, the matherr() function is called. Unless the default matherr() function is replaced, it will set the global variable errno to EDOM, and print a “DOMAIN error” diagnostic message using the stderr stream.

See also:

errno, exp(), log10(), log2(), pow(), matherr()

Examples:

#include <stdio.h>
#include <math.h>

void main()
  {
    printf( "%f\n", log(.5) );
  }

produces the output:

-0.693147

Classification:

ANSI

Systems:

Math