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