1LOGB(3P) POSIX Programmer's Manual LOGB(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 logb, logbf, logbl — radix-independent exponent
13
15 #include <math.h>
16
17 double logb(double x);
18 float logbf(float x);
19 long double logbl(long double x);
20
22 The functionality described on this reference page is aligned with the
23 ISO C standard. Any conflict between the requirements described here
24 and the ISO C standard is unintentional. This volume of POSIX.1‐2017
25 defers to the ISO C standard.
26
27 These functions shall compute the exponent of x, which is the integral
28 part of logr |x|, as a signed floating-point value, for non-zero x,
29 where r is the radix of the machine's floating-point arithmetic, which
30 is the value of FLT_RADIX defined in the <float.h> header.
31
32 If x is subnormal it is treated as though it were normalized; thus for
33 finite positive x:
34
35
36 1 <= x * FLT_RADIX-logb(x) < FLT_RADIX
37
38 An application wishing to check for error situations should set errno
39 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
40 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
41 FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
42 occurred.
43
45 Upon successful completion, these functions shall return the exponent
46 of x.
47
48 If x is ±0, logb(), logbf(), and logbl() shall return -HUGE_VAL,
49 -HUGE_VALF, and -HUGE_VALL, respectively.
50
51 On systems that support the IEC 60559 Floating-Point option, a pole
52 error shall occur;
53 otherwise, a pole error may occur.
54
55 If x is NaN, a NaN shall be returned.
56
57 If x is ±Inf, +Inf shall be returned.
58
60 These functions shall fail if:
61
62 Pole Error The value of x is ±0.
63
64 If the integer expression (math_errhandling & MATH_ERRNO)
65 is non-zero, then errno shall be set to [ERANGE]. If the
66 integer expression (math_errhandling & MATH_ERREXCEPT) is
67 non-zero, then the divide-by-zero floating-point exception
68 shall be raised.
69
70 These functions may fail if:
71
72 Pole Error The value of x is 0.
73
74 If the integer expression (math_errhandling & MATH_ERRNO)
75 is non-zero, then errno shall be set to [ERANGE]. If the
76 integer expression (math_errhandling & MATH_ERREXCEPT) is
77 non-zero, then the divide-by-zero floating-point exception
78 shall be raised.
79
80 The following sections are informative.
81
83 None.
84
86 On error, the expressions (math_errhandling & MATH_ERRNO) and
87 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
88 at least one of them must be non-zero.
89
91 None.
92
94 None.
95
97 feclearexcept(), fetestexcept(), ilogb(), scalbln()
98
99 The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of
100 Error Conditions for Mathematical Functions, <float.h>, <math.h>
101
103 Portions of this text are reprinted and reproduced in electronic form
104 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
105 table Operating System Interface (POSIX), The Open Group Base Specifi‐
106 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
107 Electrical and Electronics Engineers, Inc and The Open Group. In the
108 event of any discrepancy between this version and the original IEEE and
109 The Open Group Standard, the original IEEE and The Open Group Standard
110 is the referee document. The original Standard can be obtained online
111 at http://www.opengroup.org/unix/online.html .
112
113 Any typographical or formatting errors that appear in this page are
114 most likely to have been introduced during the conversion of the source
115 files to man page format. To report such errors, see https://www.ker‐
116 nel.org/doc/man-pages/reporting_bugs.html .
117
118
119
120IEEE/The Open Group 2017 LOGB(3P)