Debian Codegraph @

upstream/debian-unstable/man3/ilogb.3

raw
1 '\" t
2 .\" Copyright 2004, Andries E. Brouwer <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH ilogb 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 ilogb, ilogbf, ilogbl \- get integer exponent of a floating-point value
10 .SH LIBRARY
11 Math library
12 .RI ( libm ,\~ \-lm )
13 .SH SYNOPSIS
14 .nf
15 .B #include <math.h>
16 .P
17 .BI "int ilogb(double " x );
18 .BI "int ilogbf(float " x );
19 .BI "int ilogbl(long double " x );
20 .fi
21 .P
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .P
27 .BR ilogb ():
28 .nf
29 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
30 || _XOPEN_SOURCE >= 500
31 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
32 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
33 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
34 .fi
35 .P
36 .BR ilogbf (),
37 .BR ilogbl ():
38 .nf
39 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
40 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
41 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
42 .fi
43 .SH DESCRIPTION
44 These functions return the exponent part of their argument
45 as a signed integer.
46 When no error occurs, these functions
47 are equivalent to the corresponding
48 .BR logb (3)
49 functions, cast to
50 .IR int .
51 .SH RETURN VALUE
52 On success, these functions return the exponent of
53 .IR x ,
54 as a signed integer.
55 .P
56 If
57 .I x
58 is zero, then a domain error occurs, and the functions return
59 .\" the POSIX.1 spec for logb() says logb() gives pole error for this
60 .\" case, but for ilogb() it says domain error.
61 .BR FP_ILOGB0 .
62 .\" glibc: The numeric value is either `INT_MIN' or `-INT_MAX'.
63 .P
64 If
65 .I x
66 is a NaN, then a domain error occurs, and the functions return
67 .BR FP_ILOGBNAN .
68 .\" glibc: The numeric value is either `INT_MIN' or `INT_MAX'.
69 .\" On i386, FP_ILOGB0 and FP_ILOGBNAN have the same value.
70 .P
71 If
72 .I x
73 is negative infinity or positive infinity, then
74 a domain error occurs, and the functions return
75 .BR INT_MAX .
76 .\"
77 .\" POSIX.1-2001 also says:
78 .\" If the correct value is greater than {INT_MAX}, {INT_MAX}
79 .\" shall be returned and a domain error shall occur.
80 .\"
81 .\" If the correct value is less than {INT_MIN}, {INT_MIN}
82 .\" shall be returned and a domain error shall occur.
83 .SH ERRORS
84 See
85 .BR math_error (7)
86 for information on how to determine whether an error has occurred
87 when calling these functions.
88 .P
89 The following errors can occur:
90 .TP
91 Domain error: \f[I]x\f[] is 0 or a NaN
92 An invalid floating-point exception
93 .RB ( FE_INVALID )
94 is raised, and
95 .I errno
96 is set to
97 .B EDOM
98 (but see BUGS).
99 .TP
100 Domain error: \f[I]x\f[] is an infinity
101 An invalid floating-point exception
102 .RB ( FE_INVALID )
103 is raised, and
104 .I errno
105 is set to
106 .B EDOM
107 (but see BUGS).
108 .SH ATTRIBUTES
109 For an explanation of the terms used in this section, see
110 .BR attributes (7).
111 .TS
112 allbox;
113 lbx lb lb
114 l l l.
115 Interface Attribute Value
116 T{
117 .na
118 .nh
119 .BR ilogb (),
120 .BR ilogbf (),
121 .BR ilogbl ()
122 T} Thread safety MT-Safe
123 .TE
124 .SH STANDARDS
125 C11, POSIX.1-2008.
126 .SH HISTORY
127 C99, POSIX.1-2001.
128 .SH BUGS
129 .\" Bug raised: https://www.sourceware.org/bugzilla/show_bug.cgi?id=6794
130 Before glibc 2.16, the following bugs existed in the
131 glibc implementation of these functions:
132 .IP \[bu] 3
133 The domain error case where
134 .I x
135 is 0 or a NaN did not cause
136 .I errno
137 to be set or (on some architectures) raise a floating-point exception.
138 .IP \[bu]
139 The domain error case where
140 .I x
141 is an infinity did not cause
142 .I errno
143 to be set or raise a floating-point exception.
144 .SH SEE ALSO
145 .BR log (3),
146 .BR logb (3),
147 .BR significand (3)