Important: The information in this document is obsolete and should not be used for new development.
log
You can use thelog
function to compute the natural logarithm of a real number.
double_t log (double_t x);
x
- Any positive floating-point number.
DESCRIPTION
Thelog
function returns the natural (base e) logarithm of its argument.such that
The
exp
function performs the inverse (exponential) operation.EXCEPTIONS
When x is finite and nonzero, the result of might raise one of the following exceptions:
- inexact (for all finite, nonzero values of x other than +1)
- invalid (if x is negative)
SPECIAL CASES
Table 10-14 shows the results when the argument to thelog
function is a zero, a NaN, or an Infinity, plus other special cases for thelog
function.
Special cases for the log
functionOperation Result Exceptions raised for x < 0 NaN Invalid +0 None Divide-by-zero Divide-by-zero NaN None[35] + None NaN Invalid
EXAMPLES
z = log(+1.0); /* z = +0.0 because e0 = 1 */ z = log(-1.0); /* z = NAN because negative arguments are not allowed. The invalid exception is raised. */
[35] If the NaN is a signaling NaN, the invalid exception is raised.