Debian Codegraph @

upstream/debian-trixie/man3/logb.3

raw
1 '\" t
2 .\" Copyright 2004 Andries Brouwer <[email protected]>.
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <[email protected]>
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .\" Inspired by a page by Walter Harms created 2002-08-10
9 .\"
10 .TH logb 3 2024-05-02 "Linux man-pages 6.9.1"
11 .SH NAME
12 logb, logbf, logbl \- get exponent of a floating-point value
13 .SH LIBRARY
14 Math library
15 .RI ( libm ", " \-lm )
16 .SH SYNOPSIS
17 .nf
18 .B #include <math.h>
19 .P
20 .BI "double logb(double " x );
21 .BI "float logbf(float " x );
22 .BI "long double logbl(long double " x );
23 .fi
24 .P
25 .RS -4
26 Feature Test Macro Requirements for glibc (see
27 .BR feature_test_macros (7)):
28 .RE
29 .P
30 .BR logb ():
31 .nf
32 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
33 || _XOPEN_SOURCE >= 500
34 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
35 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
36 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
37 .fi
38 .P
39 .BR logbf (),
40 .BR logbl ():
41 .nf
42 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
43 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
44 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
45 .fi
46 .SH DESCRIPTION
47 These functions extract the exponent from the
48 internal floating-point representation of
49 .I x
50 and return it as a floating-point value.
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.
56 If
57 .B FLT_RADIX
58 is 2,
59 .BI logb( x )
60 is similar to
61 .BI floor(log2(fabs( x )))\f[R],\f[]
62 except that the latter may give an incorrect integer
63 due to intermediate rounding.
64 .P
65 If
66 .I x
67 is subnormal,
68 .BR logb ()
69 returns the exponent
70 .I x
71 would have if it were normalized.
72 .SH RETURN VALUE
73 On success, these functions return the exponent of
74 .IR x .
75 .P
76 If
77 .I x
78 is a NaN,
79 a NaN is returned.
80 .P
81 If
82 .I x
83 is zero, then a pole error occurs, and the functions return
84 .RB \- HUGE_VAL ,
85 .RB \- HUGE_VALF ,
86 or
87 .RB \- HUGE_VALL ,
88 respectively.
89 .P
90 If
91 .I x
92 is negative infinity or positive infinity, then
93 positive infinity is returned.
94 .SH ERRORS
95 See
96 .BR math_error (7)
97 for information on how to determine whether an error has occurred
98 when calling these functions.
99 .P
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.
109 .P
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
114 .\" Bug raised: https://www.sourceware.org/bugzilla/show_bug.cgi?id=6793
115 .\"
116 .SH ATTRIBUTES
117 For an explanation of the terms used in this section, see
118 .BR attributes (7).
119 .TS
120 allbox;
121 lbx lb lb
122 l l l.
123 Interface Attribute Value
124 T{
125 .na
126 .nh
127 .BR logb (),
128 .BR logbf (),
129 .BR logbl ()
130 T} Thread safety MT-Safe
131 .TE
132 .SH STANDARDS
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).
140 .SH SEE ALSO
141 .BR ilogb (3),
142 .BR log (3)