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