]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/log.3
Many pages: Fix style issues reported by `make lint-groff`
[thirdparty/man-pages.git] / man3 / log.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
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 .\"
16 .TH LOG 3 2021-03-22 GNU "Linux Programmer's Manual"
17 .SH NAME
18 log, logf, logl \- natural logarithmic function
19 .SH LIBRARY
20 Math library
21 .RI ( libm ", " \-lm )
22 .SH SYNOPSIS
23 .nf
24 .B #include <math.h>
25 .PP
26 .BI "double log(double " x );
27 .BI "float logf(float " x );
28 .BI "long double logl(long double " x );
29 .fi
30 .PP
31 .RS -4
32 Feature Test Macro Requirements for glibc (see
33 .BR feature_test_macros (7)):
34 .RE
35 .PP
36 .BR logf (),
37 .BR logl ():
38 .nf
39 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
40 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
41 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
42 .fi
43 .SH DESCRIPTION
44 These functions return the natural logarithm of
45 .IR x .
46 .SH RETURN VALUE
47 On success, these functions return the natural logarithm of
48 .IR x .
49 .PP
50 If
51 .I x
52 is a NaN,
53 a NaN is returned.
54 .PP
55 If
56 .I x
57 is 1, the result is +0.
58 .PP
59 If
60 .I x
61 is positive infinity,
62 positive infinity is returned.
63 .PP
64 If
65 .I x
66 is zero,
67 then a pole error occurs, and the functions return
68 .RB \- HUGE_VAL ,
69 .RB \- HUGE_VALF ,
70 or
71 .RB \- HUGE_VALL ,
72 respectively.
73 .PP
74 If
75 .I x
76 is negative (including negative infinity), then
77 a domain error occurs, and a NaN (not a number) is returned.
78 .SH ERRORS
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:
85 .TP
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.
93 .TP
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.
101 .SH ATTRIBUTES
102 For an explanation of the terms used in this section, see
103 .BR attributes (7).
104 .ad l
105 .nh
106 .TS
107 allbox;
108 lbx lb lb
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
117 .hy
118 .ad
119 .sp 1
120 .SH CONFORMING TO
121 C99, POSIX.1-2001, POSIX.1-2008.
122 .PP
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)