share/mk/: build-pdf-book: Fix chapter bookmarks
[man-pages.git] / man3 / log.3
blob2192a92945b288ac4d74bc73c76fc3109190dcdf
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\"     <mtk.manpages@gmail.com>
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
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 .\"
17 .TH log 3 (date) "Linux man-pages (unreleased)"
18 .SH NAME
19 log, logf, logl \- natural logarithmic function
20 .SH LIBRARY
21 Math library
22 .RI ( libm ", " \-lm )
23 .SH SYNOPSIS
24 .nf
25 .B #include <math.h>
27 .BI "double log(double " x );
28 .BI "float logf(float " x );
29 .BI "long double logl(long double " x );
30 .fi
32 .RS -4
33 Feature Test Macro Requirements for glibc (see
34 .BR feature_test_macros (7)):
35 .RE
37 .BR logf (),
38 .BR logl ():
39 .nf
40     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
41         || /* Since glibc 2.19: */ _DEFAULT_SOURCE
42         || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
43 .fi
44 .SH DESCRIPTION
45 These functions return the natural logarithm of
46 .IR x .
47 .SH RETURN VALUE
48 On success, these functions return the natural logarithm of
49 .IR x .
52 .I x
53 is a NaN,
54 a NaN is returned.
57 .I x
58 is 1, the result is +0.
61 .I x
62 is positive infinity,
63 positive infinity is returned.
66 .I x
67 is zero,
68 then a pole error occurs, and the functions return
69 .RB \- HUGE_VAL ,
70 .RB \- HUGE_VALF ,
72 .RB \- HUGE_VALL ,
73 respectively.
76 .I x
77 is negative (including negative infinity), then
78 a domain error occurs, and a NaN (not a number) is returned.
79 .SH ERRORS
80 See
81 .BR math_error (7)
82 for information on how to determine whether an error has occurred
83 when calling these functions.
85 The following errors can occur:
86 .TP
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.
94 .TP
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.
102 .SH ATTRIBUTES
103 For an explanation of the terms used in this section, see
104 .BR attributes (7).
106 allbox;
107 lbx lb lb
108 l l l.
109 Interface       Attribute       Value
113 .BR log (),
114 .BR logf (),
115 .BR logl ()
116 T}      Thread safety   MT-Safe
118 .SH STANDARDS
119 C11, POSIX.1-2008.
120 .SH HISTORY
121 C99, POSIX.1-2001.
123 The variant returning
124 .I double
125 also conforms to
126 SVr4, 4.3BSD, C89.
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
132 .RB ( FE_INVALID )
133 exception.
134 .SH SEE ALSO
135 .BR cbrt (3),
136 .BR clog (3),
137 .BR log10 (3),
138 .BR log1p (3),
139 .BR log2 (3),
140 .BR sqrt (3)