1log(3M) Mathematical Library Functions log(3M)
2
3
4
6 log, logf, logl - natural logarithm function
7
9 c99 [ flag... ] file... -lm [ library... ]
10 #include <math.h>
11
12 double log(double x);
13
14
15 float logf(float x);
16
17
18 long double logl(long double x);
19
20
22 These functions compute the natural logarithm of their argument x,
23 log(e)(x).
24
26 Upon successful completion, log() returns the natural logarithm of x.
27
28
29 If x is ±0, a pole error occurs and log(), logf(), and logl() return
30 −HUGE_VAL, −HUGE_VALF, and −HUGE_VALL, respectively.
31
32
33 For finite values of x that are less than 0, or if x is −Inf, a domain
34 error occurs and a NaN is returned.
35
36
37 If x is NaN, a NaN is returned.
38
39
40 If x is 1, +0 is returned.
41
42
43 If x is +Inf, x is returned.
44
45
46 For exceptional cases, matherr(3M) tabulates the values to be returned
47 by log() as specified by SVID3 and XPG3.
48
50 These functions will fail if:
51
52 Domain Error The finite value of x is negative, or x is -Inf.
53
54 If the integer expression (math_errhandling &
55 MATH_ERREXCEPT) is non-zero, the invalid floating-point
56 exception is raised.
57
58 The log() function sets errno to EDOM if the value of x
59 is negative.
60
61
62 Pole Error The value of x is 0.
63
64 If the integer expression (math_errhandling &
65 MATH_ERREXCEPT) is non-zero, the divide-by-zero float‐
66 ing-point exception is raised.
67
68
70 An application wanting to check for exceptions should call feclearex‐
71 cept(FE_ALL_EXCEPT) before calling these functions. On return, if
72 fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is
73 non-zero, an exception has been raised. An application should either
74 examine the return value or check the floating point exception flags to
75 detect exceptions.
76
77
78 An application can also set errno to 0 before calling log(). On return,
79 if errno is non-zero, an error has occurred. The logf() and logl()
80 functions do not set errno.
81
83 See attributes(5) for descriptions of the following attributes:
84
85
86
87
88 ┌─────────────────────────────┬─────────────────────────────┐
89 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
90 ├─────────────────────────────┼─────────────────────────────┤
91 │Interface Stability │Standard │
92 ├─────────────────────────────┼─────────────────────────────┤
93 │MT-Level │MT-Safe │
94 └─────────────────────────────┴─────────────────────────────┘
95
97 exp(3M), feclearexcept(3M), fetestexcept(3M), isnan(3M), log10(3M),
98 log1p(3M), math.h(3HEAD), matherr(3M), attributes(5), standards(5)
99
100
101
102SunOS 5.11 12 Jul 2006 log(3M)