C++ Programming/Code/Standard C Library/Functions/log
< C++ Programming < Code < Standard C Library < Functionslog
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);
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.