]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
fea681da | 2 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
5109fcf9 MK |
3 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
4 | .\" <mtk.manpages@gmail.com> | |
fea681da | 5 | .\" |
5fbde956 | 6 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
7 | .\" |
8 | .\" References consulted: | |
9 | .\" Linux libc source code | |
10 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
11 | .\" 386BSD man pages | |
12 | .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) | |
13 | .\" Modified 1995-08-14 by Arnt Gulbrandsen <agulbra@troll.no> | |
14 | .\" Modified 2002-07-27 by Walter Harms | |
15 | .\" (walter.harms@informatik.uni-oldenburg.de) | |
16 | .\" | |
4c1c5274 | 17 | .TH log 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
18 | .SH NAME |
19 | log, logf, logl \- natural logarithmic function | |
b73c05fc AC |
20 | .SH LIBRARY |
21 | Math library | |
8fc3b2cf | 22 | .RI ( libm ", " \-lm ) |
fea681da MK |
23 | .SH SYNOPSIS |
24 | .nf | |
25 | .B #include <math.h> | |
68e4db0a | 26 | .PP |
fea681da | 27 | .BI "double log(double " x ); |
fea681da | 28 | .BI "float logf(float " x ); |
fea681da MK |
29 | .BI "long double logl(long double " x ); |
30 | .fi | |
68e4db0a | 31 | .PP |
d39ad78f | 32 | .RS -4 |
5109fcf9 MK |
33 | Feature Test Macro Requirements for glibc (see |
34 | .BR feature_test_macros (7)): | |
d39ad78f | 35 | .RE |
68e4db0a | 36 | .PP |
5109fcf9 MK |
37 | .BR logf (), |
38 | .BR logl (): | |
9d2adbae | 39 | .nf |
5c10d2c5 | 40 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 41 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
75c018a1 | 42 | || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
9d2adbae | 43 | .fi |
fea681da | 44 | .SH DESCRIPTION |
5600f73a | 45 | These functions return the natural logarithm of |
022671eb | 46 | .IR x . |
5109fcf9 MK |
47 | .SH RETURN VALUE |
48 | On success, these functions return the natural logarithm of | |
49 | .IR x . | |
847e0d88 | 50 | .PP |
5109fcf9 MK |
51 | If |
52 | .I x | |
53 | is a NaN, | |
54 | a NaN is returned. | |
847e0d88 | 55 | .PP |
5109fcf9 MK |
56 | If |
57 | .I x | |
58 | is 1, the result is +0. | |
847e0d88 | 59 | .PP |
5109fcf9 MK |
60 | If |
61 | .I x | |
62 | is positive infinity, | |
63 | positive infinity is returned. | |
847e0d88 | 64 | .PP |
5109fcf9 MK |
65 | If |
66 | .I x | |
67 | is zero, | |
efe294cb | 68 | then a pole error occurs, and the functions return |
cd415e73 MK |
69 | .RB \- HUGE_VAL , |
70 | .RB \- HUGE_VALF , | |
5109fcf9 | 71 | or |
cd415e73 | 72 | .RB \- HUGE_VALL , |
5109fcf9 | 73 | respectively. |
847e0d88 | 74 | .PP |
5109fcf9 MK |
75 | If |
76 | .I x | |
77 | is negative (including negative infinity), then | |
efe294cb | 78 | a domain error occurs, and a NaN (not a number) is returned. |
fea681da | 79 | .SH ERRORS |
5109fcf9 MK |
80 | See |
81 | .BR math_error (7) | |
82 | for information on how to determine whether an error has occurred | |
83 | when calling these functions. | |
84 | .PP | |
85 | The following errors can occur: | |
fea681da | 86 | .TP |
5109fcf9 MK |
87 | Domain error: \fIx\fP is negative |
88 | .I errno | |
89 | is set to | |
90 | .BR EDOM . | |
91 | An invalid floating-point exception | |
92 | .RB ( FE_INVALID ) | |
93 | is raised. | |
fea681da | 94 | .TP |
5109fcf9 MK |
95 | Pole error: \fIx\fP is zero |
96 | .I errno | |
97 | is set to | |
98 | .BR ERANGE . | |
99 | A divide-by-zero floating-point exception | |
100 | .RB ( FE_DIVBYZERO ) | |
101 | is raised. | |
83afbd20 MS |
102 | .SH ATTRIBUTES |
103 | For an explanation of the terms used in this section, see | |
104 | .BR attributes (7). | |
105 | .TS | |
106 | allbox; | |
c466875e | 107 | lbx lb lb |
83afbd20 MS |
108 | l l l. |
109 | Interface Attribute Value | |
110 | T{ | |
9e54434e BR |
111 | .na |
112 | .nh | |
83afbd20 MS |
113 | .BR log (), |
114 | .BR logf (), | |
115 | .BR logl () | |
116 | T} Thread safety MT-Safe | |
117 | .TE | |
c466875e | 118 | .sp 1 |
3113c7f3 | 119 | .SH STANDARDS |
4131356c AC |
120 | C11, POSIX.1-2008. |
121 | .SH HISTORY | |
122 | C99, POSIX.1-2001. | |
847e0d88 | 123 | .PP |
5109fcf9 MK |
124 | The variant returning |
125 | .I double | |
126 | also conforms to | |
e0089d55 | 127 | SVr4, 4.3BSD, C89. |
5625342f MK |
128 | .SH BUGS |
129 | In glibc 2.5 and earlier, | |
130 | taking the | |
131 | .BR log () | |
132 | of a NaN produces a bogus invalid floating-point | |