log - natural logarithm function
cc [ flag ... ] file ... -lm [ library ... ]
double log(double x);
The log() function computes the natural logarithm of x,
loge(x). The value of x must be positive.
Upon successful completion, log() returns the natural loga-
rithm of x.
If x is NaN, NaN is returned.
If x is less than 0, -HUGE_VAL or NaN is returned and errno
is set to EDOM.
If x is 0, -HUGE_VAL is returned and errno may be set to
In IEEE754 mode (the -Xlibmieee cc compilation option), if x
is Inf or a quiet NaN, x is returned; if x is a signaling
NaN, a quiet NaN is returned and the invalid operation
exception is raised; if x is 1, 0 is returned; for all other
positive x, a normalized number is returned and the inexact
exception is raised.
For exceptional cases, matherr(3M) tabulates the values to
be returned as dictated by Standards other than XPG4.
The log() function will fail if:
EDOM The value of x is negative.
The log() function may fail if:
The value of x is 0.
No other errors will occur.
An application wishing to check for error situations should
set errno to 0 before calling log(). If errno is non-zero on
return, or the return value is NaN, an error has occurred.
See attributes(5) for descriptions of the following attri-
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | MT-Safe |
exp(3M), isnan(3M), log10(3M), log1p(3M), matherr(3M),
Man(1) output converted with