1
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
5
log, logf, logl \- natural logarithm function
11
double log(double\fP \fIx\fP\fB);
13
float logf(float\fP \fIx\fP\fB);
15
long double logl(long double\fP \fIx\fP\fB);
20
These functions shall compute the natural logarithm of their argument
24
An application wishing to check for error situations should set \fIerrno\fP
26
\fIfeclearexcept\fP(FE_ALL_EXCEPT) before calling these functions.
27
On return, if \fIerrno\fP is non-zero or
28
\fIfetestexcept\fP(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
29
is non-zero, an error has occurred.
32
Upon successful completion, these functions shall return the natural
35
If \fIx\fP is \(+-0, a pole error shall occur and \fIlog\fP(), \fIlogf\fP(),
36
and \fIlogl\fP() shall return -HUGE_VAL,
37
-HUGE_VALF, and -HUGE_VALL, respectively.
39
For finite values of \fIx\fP that are less than 0, \ or if \fIx\fP
40
is -Inf, a domain error shall occur, and \ either a NaN (if supported),
41
or \ an implementation-defined value shall be returned.
44
\fIx\fP is NaN, a NaN shall be returned.
46
If \fIx\fP is 1, +0 shall be returned.
48
If \fIx\fP is +Inf, \fIx\fP shall be returned.
51
These functions shall fail if:
54
The finite value of \fIx\fP is negative, \ or \fIx\fP is -Inf.
56
If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
57
then \fIerrno\fP shall be set to [EDOM]. If the
58
integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero,
59
then the invalid floating-point exception shall be
63
The value of \fIx\fP is zero.
65
If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
66
then \fIerrno\fP shall be set to [ERANGE]. If the
67
integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero,
68
then the divide-by-zero floating-point exception shall be
72
\fIThe following sections are informative.\fP
78
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling
79
& MATH_ERREXCEPT) are independent of
80
each other, but at least one of them must be non-zero.
89
\fIexp\fP() , \fIfeclearexcept\fP() , \fIfetestexcept\fP() , \fIisnan\fP()
91
\fIlog1p\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
92
Section 4.18, Treatment of Error Conditions for Mathematical Functions,
95
Portions of this text are reprinted and reproduced in electronic form
96
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
97
-- Portable Operating System Interface (POSIX), The Open Group Base
98
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
99
Electrical and Electronics Engineers, Inc and The Open Group. In the
100
event of any discrepancy between this version and the original IEEE and
101
The Open Group Standard, the original IEEE and The Open Group Standard
102
is the referee document. The original Standard can be obtained online at
103
http://www.opengroup.org/unix/online.html .