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