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