log [C++ Reference]
Keywords: c,math,log
Date: 2009-03-19T23:46:23-0700

[[log]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## log

Syntax:

        #include <cmath>
        double log( double num );

The function log() returns the natural (base e) logarithm of num. There's a domain error if num is negative, a range error if num is zero. In order to calculate the logarithm of x to an arbitrary base b, you can use:

        double answer = log(x) / log(b);

C++ also provides the following overloaded forms:

        #include <cmath>
        float log( float num ); // same as logf() in C99
        long double log( long double num ); // same as logl() in C99

Related Topics: exp, log10, pow, sqrt

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •