1LOG(3) Linux Programmer's Manual LOG(3)
2
3
4
6 log, logf, logl - natural logarithmic function
7
9 #include <math.h>
10
11 double log(double x);
12 float logf(float x);
13 long double logl(long double x);
14
15 Link with -lm.
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 logf(), logl():
20 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
22 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
23
25 These functions return the natural logarithm of x.
26
28 On success, these functions return the natural logarithm of x.
29
30 If x is a NaN, a NaN is returned.
31
32 If x is 1, the result is +0.
33
34 If x is positive infinity, positive infinity is returned.
35
36 If x is zero, then a pole error occurs, and the functions return
37 -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively.
38
39 If x is negative (including negative infinity), then a domain error oc‐
40 curs, and a NaN (not a number) is returned.
41
43 See math_error(7) for information on how to determine whether an error
44 has occurred when calling these functions.
45
46 The following errors can occur:
47
48 Domain error: x is negative
49 errno is set to EDOM. An invalid floating-point exception
50 (FE_INVALID) is raised.
51
52 Pole error: x is zero
53 errno is set to ERANGE. A divide-by-zero floating-point excep‐
54 tion (FE_DIVBYZERO) is raised.
55
57 For an explanation of the terms used in this section, see at‐
58 tributes(7).
59
60 ┌──────────────────────┬───────────────┬─────────┐
61 │Interface │ Attribute │ Value │
62 ├──────────────────────┼───────────────┼─────────┤
63 │log(), logf(), logl() │ Thread safety │ MT-Safe │
64 └──────────────────────┴───────────────┴─────────┘
66 C99, POSIX.1-2001, POSIX.1-2008.
67
68 The variant returning double also conforms to SVr4, 4.3BSD, C89.
69
71 In glibc 2.5 and earlier, taking the log() of a NaN produces a bogus
72 invalid floating-point (FE_INVALID) exception.
73
75 cbrt(3), clog(3), log10(3), log1p(3), log2(3), sqrt(3)
76
78 This page is part of release 5.10 of the Linux man-pages project. A
79 description of the project, information about reporting bugs, and the
80 latest version of this page, can be found at
81 https://www.kernel.org/doc/man-pages/.
82
83
84
85 2017-09-15 LOG(3)