1LOG(3P)                    POSIX Programmer's Manual                   LOG(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       log, logf, logl — natural logarithm function
13

SYNOPSIS

15       #include <math.h>
16
17       double log(double x);
18       float logf(float x);
19       long double logl(long double x);
20

DESCRIPTION

22       The functionality described on this reference page is aligned with  the
23       ISO C  standard.  Any  conflict between the requirements described here
24       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
25       defers to the ISO C standard.
26
27       These  functions  shall compute the natural logarithm of their argument
28       x, loge(x).
29
30       An application wishing to check for error situations should  set  errno
31       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
32       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
33       FE_DIVBYZERO  |  FE_OVERFLOW  | FE_UNDERFLOW) is non-zero, an error has
34       occurred.
35

RETURN VALUE

37       Upon successful completion, these functions shall  return  the  natural
38       logarithm of x.
39
40       If  x  is  ±0,  a  pole error shall occur and log(), logf(), and logl()
41       shall return -HUGE_VAL, -HUGE_VALF, and -HUGE_VALL, respectively.
42
43       For finite values of x that are less than 0, or if x is -Inf, a  domain
44       error  shall  occur, and either a NaN (if supported), or an implementa‐
45       tion-defined value shall be returned.
46
47       If x is NaN, a NaN shall be returned.
48
49       If x is 1, +0 shall be returned.
50
51       If x is +Inf, x shall be returned.
52

ERRORS

54       These functions shall fail if:
55
56       Domain Error
57                   The finite value of x is negative, or x is -Inf.
58
59                   If the integer expression (math_errhandling  &  MATH_ERRNO)
60                   is  non-zero,  then  errno  shall be set to [EDOM].  If the
61                   integer expression (math_errhandling &  MATH_ERREXCEPT)  is
62                   non-zero,  then  the invalid floating-point exception shall
63                   be raised.
64
65       Pole Error  The value of x is zero.
66
67                   If the integer expression (math_errhandling  &  MATH_ERRNO)
68                   is  non-zero,  then errno shall be set to [ERANGE].  If the
69                   integer expression (math_errhandling &  MATH_ERREXCEPT)  is
70                   non-zero,  then the divide-by-zero floating-point exception
71                   shall be raised.
72
73       The following sections are informative.
74

EXAMPLES

76       None.
77

APPLICATION USAGE

79       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
80       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
81       at least one of them must be non-zero.
82

RATIONALE

84       None.
85

FUTURE DIRECTIONS

87       None.
88

SEE ALSO

90       exp(), feclearexcept(), fetestexcept(), isnan(), log10(), log1p()
91
92       The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of
93       Error Conditions for Mathematical Functions, <math.h>
94
96       Portions  of  this text are reprinted and reproduced in electronic form
97       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
98       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
99       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
100       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
101       event of any discrepancy between this version and the original IEEE and
102       The  Open Group Standard, the original IEEE and The Open Group Standard
103       is the referee document. The original Standard can be  obtained  online
104       at http://www.opengroup.org/unix/online.html .
105
106       Any  typographical  or  formatting  errors that appear in this page are
107       most likely to have been introduced during the conversion of the source
108       files  to  man page format. To report such errors, see https://www.ker
109       nel.org/doc/man-pages/reporting_bugs.html .
110
111
112
113IEEE/The Open Group                  2017                              LOG(3P)
Impressum