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>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" References consulted:
8 .\" Linux libc source code
9 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
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)
16 .TH log 3 (date) "Linux man-pages (unreleased)"
18 log, logf, logl \- natural logarithmic function
21 .RI ( libm ", " \-lm )
26 .BI "double log(double " x );
27 .BI "float logf(float " x );
28 .BI "long double logl(long double " x );
32 Feature Test Macro Requirements for glibc (see
33 .BR feature_test_macros (7)):
39 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
40 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
41 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
44 These functions return the natural logarithm of
47 On success, these functions return the natural logarithm of
57 is 1, the result is +0.
62 positive infinity is returned.
67 then a pole error occurs, and the functions return
76 is negative (including negative infinity), then
77 a domain error occurs, and a NaN (not a number) is returned.
81 for information on how to determine whether an error has occurred
82 when calling these functions.
84 The following errors can occur:
86 Domain error: \fIx\fP is negative
90 An invalid floating-point exception
94 Pole error: \fIx\fP is zero
98 A divide-by-zero floating-point exception
102 For an explanation of the terms used in this section, see
110 Interface Attribute Value
115 T} Thread safety MT-Safe
121 C99, POSIX.1-2001, POSIX.1-2008.
123 The variant returning
128 In glibc 2.5 and earlier,
131 of a NaN produces a bogus invalid floating-point