]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
fea681da | 2 | .\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>. |
cdf1aadc MK |
3 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
4 | .\" <mtk.manpages@gmail.com> | |
fea681da | 5 | .\" |
5fbde956 | 6 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
7 | .\" |
8 | .\" Inspired by a page by Walter Harms created 2002-08-10 | |
9 | .\" | |
4c1c5274 | 10 | .TH logb 3 (date) "Linux man-pages (unreleased)" |
fea681da | 11 | .SH NAME |
cdf1aadc | 12 | logb, logbf, logbl \- get exponent of a floating-point value |
ee60e844 AC |
13 | .SH LIBRARY |
14 | Math library | |
8fc3b2cf | 15 | .RI ( libm ", " \-lm ) |
fea681da | 16 | .SH SYNOPSIS |
c7db92b9 | 17 | .nf |
fea681da | 18 | .B #include <math.h> |
c6d039a3 | 19 | .P |
fea681da | 20 | .BI "double logb(double " x ); |
fea681da | 21 | .BI "float logbf(float " x ); |
fea681da | 22 | .BI "long double logbl(long double " x ); |
c7db92b9 | 23 | .fi |
c6d039a3 | 24 | .P |
d39ad78f | 25 | .RS -4 |
cc4615cc MK |
26 | Feature Test Macro Requirements for glibc (see |
27 | .BR feature_test_macros (7)): | |
d39ad78f | 28 | .RE |
c6d039a3 | 29 | .P |
cdf1aadc | 30 | .BR logb (): |
9d2adbae | 31 | .nf |
5c10d2c5 MK |
32 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
33 | || _XOPEN_SOURCE >= 500 | |
34 | .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED | |
9d2adbae | 35 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
75c018a1 | 36 | || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
9d2adbae | 37 | .fi |
c6d039a3 | 38 | .P |
cc4615cc MK |
39 | .BR logbf (), |
40 | .BR logbl (): | |
9d2adbae | 41 | .nf |
5c10d2c5 | 42 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 43 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
75c018a1 | 44 | || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
9d2adbae | 45 | .fi |
fea681da | 46 | .SH DESCRIPTION |
cdf1aadc MK |
47 | These functions extract the exponent from the |
48 | internal floating-point representation of | |
fea681da | 49 | .I x |
c13182ef | 50 | and return it as a floating-point value. |
cdf1aadc MK |
51 | The integer constant |
52 | .BR FLT_RADIX , | |
53 | defined in | |
54 | .IR <float.h> , | |
55 | indicates the radix used for the system's floating-point representation. | |
c13182ef | 56 | If |
fea681da | 57 | .B FLT_RADIX |
cdf1aadc | 58 | is 2, |
c13182ef | 59 | .BI logb( x ) |
a4ea5f76 | 60 | is similar to |
cf26f5ed | 61 | .BI floor(log2(fabs( x )))\f[R],\f[] |
a4ea5f76 AC |
62 | except that the latter may give an incorrect integer |
63 | due to intermediate rounding. | |
c6d039a3 | 64 | .P |
fea681da MK |
65 | If |
66 | .I x | |
cdf1aadc | 67 | is subnormal, |
63aa9df0 | 68 | .BR logb () |
fea681da MK |
69 | returns the exponent |
70 | .I x | |
71 | would have if it were normalized. | |
cdf1aadc MK |
72 | .SH RETURN VALUE |
73 | On success, these functions return the exponent of | |
74 | .IR x . | |
c6d039a3 | 75 | .P |
fea681da MK |
76 | If |
77 | .I x | |
cdf1aadc MK |
78 | is a NaN, |
79 | a NaN is returned. | |
c6d039a3 | 80 | .P |
fea681da MK |
81 | If |
82 | .I x | |
efe294cb | 83 | is zero, then a pole error occurs, and the functions return |
cd415e73 MK |
84 | .RB \- HUGE_VAL , |
85 | .RB \- HUGE_VALF , | |
cdf1aadc | 86 | or |
cd415e73 | 87 | .RB \- HUGE_VALL , |
cdf1aadc | 88 | respectively. |
c6d039a3 | 89 | .P |
fea681da MK |
90 | If |
91 | .I x | |
cdf1aadc MK |
92 | is negative infinity or positive infinity, then |
93 | positive infinity is returned. | |
fea681da | 94 | .SH ERRORS |
cdf1aadc MK |
95 | See |
96 | .BR math_error (7) | |
97 | for information on how to determine whether an error has occurred | |
98 | when calling these functions. | |
c6d039a3 | 99 | .P |
cdf1aadc MK |
100 | The following errors can occur: |
101 | .TP | |
102 | Pole error: \fIx\fP is 0 | |
103 | .\" .I errno | |
104 | .\" is set to | |
105 | .\" .BR ERANGE . | |
106 | A divide-by-zero floating-point exception | |
107 | .RB ( FE_DIVBYZERO ) | |
108 | is raised. | |
c6d039a3 | 109 | .P |
cdf1aadc MK |
110 | These functions do not set |
111 | .IR errno . | |
112 | .\" FIXME . Is it intentional that these functions do not set errno? | |
113 | .\" log(), log2(), log10() do set errno | |
fd00f831 | 114 | .\" Bug raised: https://www.sourceware.org/bugzilla/show_bug.cgi?id=6793 |
cdf1aadc | 115 | .\" |
31d47454 | 116 | .SH ATTRIBUTES |
399fa11f PH |
117 | For an explanation of the terms used in this section, see |
118 | .BR attributes (7). | |
119 | .TS | |
120 | allbox; | |
c466875e | 121 | lbx lb lb |
399fa11f PH |
122 | l l l. |
123 | Interface Attribute Value | |
124 | T{ | |
9e54434e BR |
125 | .na |
126 | .nh | |
31d47454 PH |
127 | .BR logb (), |
128 | .BR logbf (), | |
31d47454 | 129 | .BR logbl () |
399fa11f PH |
130 | T} Thread safety MT-Safe |
131 | .TE | |
3113c7f3 | 132 | .SH STANDARDS |
4131356c AC |
133 | C11, POSIX.1-2008. |
134 | .SH HISTORY | |
135 | C99, POSIX.1-2001. | |
136 | .TP | |
137 | .BR logb () | |
138 | 4.3BSD | |
139 | (see IEEE.3 in the 4.3BSD manual). | |
47297adb | 140 | .SH SEE ALSO |
f0c34053 MK |
141 | .BR ilogb (3), |
142 | .BR log (3) |