log - C math.h

C examples for math.h:log

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns the natural logarithm of x.

The natural logarithm is the base-e logarithm: the inverse of the natural exponential function exp.

Prototype

long double logl (long double x);
long double log (long double x);
     double log (double x);
      float logf(float x);
      float log (float x);
     double log (T x);           

Parameters

Parameter Description
x Value whose logarithm is calculated. If the argument is negative, a domain error occurs.

Return Value

Natural logarithm of x.

Demo Code

#include <stdio.h>
#include <math.h> /* log */

int main ()/*from w ww .  ja v a 2 s .  c o  m*/
{
  double param = 15.5;
  double result = log (param);
  printf ("log(%f) = %f\n", param, result );
  return 0;
}

Related Tutorials