Main index | Section 3 | 日本語 | Deutsch | Options |

Math Library (libm, -lm)

#include <math.h>

The
`log()`,
`logf()`,
and
`logl()`
functions compute the natural logarithm of
x.

The
`log10()`,
`log10f()`,
and
`log10l()`
functions compute the logarithm base 10 of
x,
while
`log2()`,
`log2f()`,
and
`log2l()`
compute the logarithm base 2 of
x.

The
`log1p()`,
`log1pf()`,
and
`log1pl()`
functions compute the natural logarithm of
1 + x.
Computing the natural logarithm as
`log1p(x)`
is more accurate than computing it as
`log(1 + x)`
when
x
is close to zero.

These functions return the requested logarithm; the logarithm of 1 is +0.
An attempt to take the logarithm of ±0 results in a divide-by-zero
exception, and -∞ is returned.
Otherwise, attempting to take the logarithm of a negative number
results in an invalid exception and a return value of NaN.

The
`log()`,
`logf()`,
`logl()`,
`log10()`,
`log10f()`,
`log10l()`,
`log2()`,
`log2f()`,
`log2l()`,
`log1p()`,
`log1pf()`,
and
`log1pl()`
functions conform to
ISO/IEC 9899:1999 ("ISO C99").

The
`log()`
function first appeared in
*AT&T v1 ;*
`log10()`
in
*AT&T v7 ;*
`log1p()`
in
*BSD 4.3 .*

LOG (3) | March 22, 2020 |

Main index | Section 3 | 日本語 | Deutsch | Options |

Please direct any comments about this manual page service to Ben Bullock. Privacy policy.

“ | If it wasn't for C, we'd be using BASI, PASAL and OBOL | ” |