1LOGB(3) Linux Programmer's Manual LOGB(3)
2
3
4
6 logb, logbf, logbl - get exponent of a floating-point value
7
9 #include <math.h>
10
11 double logb(double x);
12 float logbf(float x);
13 long double logbl(long double x);
14
15 Link with -lm.
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 logb():
20 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21 || _XOPEN_SOURCE >= 500
22 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
23 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
24
25 logbf(), logbl():
26 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
27 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
28 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
29
31 These functions extract the exponent from the internal floating-point
32 representation of x and return it as a floating-point value. The inte‐
33 ger constant FLT_RADIX, defined in <float.h>, indicates the radix used
34 for the system's floating-point representation. If FLT_RADIX is 2,
35 logb(x) is equal to floor(log2(x)), except that it is probably faster.
36
37 If x is subnormal, logb() returns the exponent x would have if it were
38 normalized.
39
41 On success, these functions return the exponent of x.
42
43 If x is a NaN, a NaN is returned.
44
45 If x is zero, then a pole error occurs, and the functions return
46 -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively.
47
48 If x is negative infinity or positive infinity, then positive infinity
49 is returned.
50
52 See math_error(7) for information on how to determine whether an error
53 has occurred when calling these functions.
54
55 The following errors can occur:
56
57 Pole error: x is 0
58 A divide-by-zero floating-point exception (FE_DIVBYZERO) is
59 raised.
60
61 These functions do not set errno.
62
64 For an explanation of the terms used in this section, see at‐
65 tributes(7).
66
67 ┌────────────────────────────────────────────┬───────────────┬─────────┐
68 │Interface │ Attribute │ Value │
69 ├────────────────────────────────────────────┼───────────────┼─────────┤
70 │logb(), logbf(), logbl() │ Thread safety │ MT-Safe │
71 └────────────────────────────────────────────┴───────────────┴─────────┘
72
74 C99, POSIX.1-2001, POSIX.1-2008.
75
77 ilogb(3), log(3)
78
80 This page is part of release 5.12 of the Linux man-pages project. A
81 description of the project, information about reporting bugs, and the
82 latest version of this page, can be found at
83 https://www.kernel.org/doc/man-pages/.
84
85
86
87 2021-03-22 LOGB(3)