]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/log.3
man*/: ffix (un-bracket tables)
[thirdparty/man-pages.git] / man3 / log.3
CommitLineData
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
19log, logf, logl \- natural logarithmic function
b73c05fc
AC
20.SH LIBRARY
21Math 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
33Feature 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 45These functions return the natural logarithm of
022671eb 46.IR x .
5109fcf9
MK
47.SH RETURN VALUE
48On success, these functions return the natural logarithm of
49.IR x .
847e0d88 50.PP
5109fcf9
MK
51If
52.I x
53is a NaN,
54a NaN is returned.
847e0d88 55.PP
5109fcf9
MK
56If
57.I x
58is 1, the result is +0.
847e0d88 59.PP
5109fcf9
MK
60If
61.I x
62is positive infinity,
63positive infinity is returned.
847e0d88 64.PP
5109fcf9
MK
65If
66.I x
67is zero,
efe294cb 68then a pole error occurs, and the functions return
cd415e73
MK
69.RB \- HUGE_VAL ,
70.RB \- HUGE_VALF ,
5109fcf9 71or
cd415e73 72.RB \- HUGE_VALL ,
5109fcf9 73respectively.
847e0d88 74.PP
5109fcf9
MK
75If
76.I x
77is negative (including negative infinity), then
efe294cb 78a domain error occurs, and a NaN (not a number) is returned.
fea681da 79.SH ERRORS
5109fcf9
MK
80See
81.BR math_error (7)
82for information on how to determine whether an error has occurred
83when calling these functions.
84.PP
85The following errors can occur:
fea681da 86.TP
5109fcf9
MK
87Domain error: \fIx\fP is negative
88.I errno
89is set to
90.BR EDOM .
91An invalid floating-point exception
92.RB ( FE_INVALID )
93is raised.
fea681da 94.TP
5109fcf9
MK
95Pole error: \fIx\fP is zero
96.I errno
97is set to
98.BR ERANGE .
99A divide-by-zero floating-point exception
100.RB ( FE_DIVBYZERO )
101is raised.
83afbd20
MS
102.SH ATTRIBUTES
103For an explanation of the terms used in this section, see
104.BR attributes (7).
105.TS
106allbox;
c466875e 107lbx lb lb
83afbd20
MS
108l l l.
109Interface Attribute Value
110T{
9e54434e
BR
111.na
112.nh
83afbd20
MS
113.BR log (),
114.BR logf (),
115.BR logl ()
116T} Thread safety MT-Safe
117.TE
c466875e 118.sp 1
3113c7f3 119.SH STANDARDS
4131356c
AC
120C11, POSIX.1-2008.
121.SH HISTORY
122C99, POSIX.1-2001.
847e0d88 123.PP
5109fcf9
MK
124The variant returning
125.I double
126also conforms to
e0089d55 127SVr4, 4.3BSD, C89.
5625342f
MK
128.SH BUGS
129In glibc 2.5 and earlier,
130taking the
131.BR log ()
132of a NaN produces a bogus invalid floating-point