NAME
log, logf,
log10, log10f,
log1p, log1pf,
log2, log2f —
logarithm functions
LIBRARY
library “libm”
SYNOPSIS
#include
<math.h>
double
log(double
x);
float
logf(float
x);
double
log10(double
x);
float
log10f(float
x);
double
log1p(double
x);
float
log1pf(float
x);
double
log2(double
x);
float
log2f(float
x);
DESCRIPTION
The following functions compute logarithms:- The
log() andlogf() functions return the natural logarithm. - The
log10() andlog10f() functions return the base 10 logarithm. - The
log1p() andlog1pf() functions return the natural logarithm of (1.0 + x) accurately even for very small values of x. - The
log2() andlog2f() functions return the base 2 logarithm.
RETURN VALUES
Upon successful completion, the functions return the logarithm of x as described above. Otherwise the following may occur:
- If x is NaN, all functions return NaN.
- If x is positive infinity, all functions return x. If x is negative infinity, all functions return NaN.
- If x is +0.0 or -0.0, the
log(),log10(), andlog2() families return either-HUGE_VAL,-HUGE_VALF, or-HUGE_VALL, whereas thelog1p() family returns x. - If x is +1.0, the
log(),log10(), andlog2() families return +0.0. If x is -1.0, thelog1p() 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.
SEE ALSO
STANDARDS
The described functions conform to ISO/IEC 9899:1999 (“ISO C99”).
HISTORY
A log() function appeared in
Version 1 AT&T UNIX.