| LOG(3) | Library Functions Manual | LOG(3) |
log, logf,
logl, log10,
log10f, log10l,
log1p, log1pf,
log1pl, log2,
log2f log2l —
logarithm functions
Math Library (libm, -lm)
#include
<math.h>
double
log(double
x);
float
logf(float
x);
long double
logl(long
double x);
double
log10(double
x);
float
log10f(float
x);
log double
log10l(long
double x);
double
log1p(double
x);
float
log1pf(float
x);
long double
log1pl(long
double x);
double
log2(double
x);
float
log2f(float
x);
long double
log2l(long
double x);
The following functions compute logarithms:
log(),
logf()
and
logl()
functions return the natural logarithm.log10(),
log10f()
and
log10l()
functions return the base 10 logarithm.log1p(),
log1pf()
and
log1pl()
functions return the natural logarithm of (1.0 + x)
accurately even for very small values of x.log2(),
log2f()
and
log2l()
functions return the base 2 logarithm.Upon successful completion, the functions return the logarithm of x as described above. Otherwise the following may occur:
log(), log10(), and
log2() families return either
-HUGE_VAL, -HUGE_VALF, or
-HUGE_VALL, whereas the
log1p() family returns
x.log(),
log10(), and log2()
families return +0.0. If x is -1.0, the
log1p() family returns
-HUGE_VAL, -HUGE_VALF, or
-HUGE_VALL.In addition, on a VAX, errno is set to
EDOM and the reserved operand is returned by
log() unless x > 0, by
log1p() unless x > -1.
The described functions conform to ISO/IEC 9899:1999 (“ISO C99”).
A log() function appeared in
Version 1 AT&T UNIX.
| January 24, 2024 | NetBSD 11.0 |