Debian Codegraph @

upstream/debian-unstable/man3/log.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH log 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 log, logf, logl \- natural logarithmic function
10 .SH LIBRARY
11 Math library
12 .RI ( libm ,\~ \-lm )
13 .SH SYNOPSIS
14 .nf
15 .B #include <math.h>
16 .P
17 .BI "double log(double " x );
18 .BI "float logf(float " x );
19 .BI "long double logl(long double " x );
20 .fi
21 .P
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .P
27 .BR logf (),
28 .BR logl ():
29 .nf
30 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
31 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
32 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
33 .fi
34 .SH DESCRIPTION
35 These functions return the natural logarithm of
36 .IR x .
37 .SH RETURN VALUE
38 On success, these functions return the natural logarithm of
39 .IR x .
40 .P
41 If
42 .I x
43 is a NaN,
44 a NaN is returned.
45 .P
46 If
47 .I x
48 is 1, the result is +0.
49 .P
50 If
51 .I x
52 is positive infinity,
53 positive infinity is returned.
54 .P
55 If
56 .I x
57 is zero,
58 then a pole error occurs, and the functions return
59 .RB \- HUGE_VAL ,
60 .RB \- HUGE_VALF ,
61 or
62 .RB \- HUGE_VALL ,
63 respectively.
64 .P
65 If
66 .I x
67 is negative (including negative infinity), then
68 a domain error occurs, and a NaN (not a number) is returned.
69 .SH ERRORS
70 See
71 .BR math_error (7)
72 for information on how to determine whether an error has occurred
73 when calling these functions.
74 .P
75 The following errors can occur:
76 .TP
77 Domain error: \f[I]x\f[] is negative
78 .I errno
79 is set to
80 .BR EDOM .
81 An invalid floating-point exception
82 .RB ( FE_INVALID )
83 is raised.
84 .TP
85 Pole error: \f[I]x\f[] is zero
86 .I errno
87 is set to
88 .BR ERANGE .
89 A divide-by-zero floating-point exception
90 .RB ( FE_DIVBYZERO )
91 is raised.
92 .SH ATTRIBUTES
93 For an explanation of the terms used in this section, see
94 .BR attributes (7).
95 .TS
96 allbox;
97 lbx lb lb
98 l l l.
99 Interface Attribute Value
100 T{
101 .na
102 .nh
103 .BR log (),
104 .BR logf (),
105 .BR logl ()
106 T} Thread safety MT-Safe
107 .TE
108 .SH STANDARDS
109 C11, POSIX.1-2008.
110 .SH HISTORY
111 C99, POSIX.1-2001.
112 .P
113 The variant returning
114 .I double
115 also conforms to
116 SVr4, 4.3BSD, C89.
117 .SH BUGS
118 In glibc 2.5 and earlier,
119 taking the
120 .BR log ()
121 of a NaN produces a bogus invalid floating-point
122 .RB ( FE_INVALID )
123 exception.
124 .SH SEE ALSO
125 .BR cbrt (3),
126 .BR clog (3),
127 .BR log10 (3),
128 .BR log1p (3),
129 .BR log2 (3),
130 .BR sqrt (3)