]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/ilogb.3
76266f3efdcad621077011ca3fc24928baed2a5b
[thirdparty/man-pages.git] / man3 / ilogb.3
1 '\" t
2 .\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>.
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <mtk.manpages@gmail.com>
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 ilogb 3 (date) "Linux man-pages (unreleased)"
11 .SH NAME
12 ilogb, ilogbf, ilogbl \- get integer 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 .PP
20 .BI "int ilogb(double " x );
21 .BI "int ilogbf(float " x );
22 .BI "int ilogbl(long double " x );
23 .fi
24 .PP
25 .RS -4
26 Feature Test Macro Requirements for glibc (see
27 .BR feature_test_macros (7)):
28 .RE
29 .PP
30 .BR ilogb ():
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 .PP
39 .BR ilogbf (),
40 .BR ilogbl ():
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 return the exponent part of their argument
48 as a signed integer.
49 When no error occurs, these functions
50 are equivalent to the corresponding
51 .BR logb (3)
52 functions, cast to
53 .IR int .
54 .SH RETURN VALUE
55 On success, these functions return the exponent of
56 .IR x ,
57 as a signed integer.
58 .PP
59 If
60 .I x
61 is zero, then a domain error occurs, and the functions return
62 .\" the POSIX.1 spec for logb() says logb() gives pole error for this
63 .\" case, but for ilogb() it says domain error.
64 .BR FP_ILOGB0 .
65 .\" glibc: The numeric value is either `INT_MIN' or `-INT_MAX'.
66 .PP
67 If
68 .I x
69 is a NaN, then a domain error occurs, and the functions return
70 .BR FP_ILOGBNAN .
71 .\" glibc: The numeric value is either `INT_MIN' or `INT_MAX'.
72 .\" On i386, FP_ILOGB0 and FP_ILOGBNAN have the same value.
73 .PP
74 If
75 .I x
76 is negative infinity or positive infinity, then
77 a domain error occurs, and the functions return
78 .BR INT_MAX .
79 .\"
80 .\" POSIX.1-2001 also says:
81 .\" If the correct value is greater than {INT_MAX}, {INT_MAX}
82 .\" shall be returned and a domain error shall occur.
83 .\"
84 .\" If the correct value is less than {INT_MIN}, {INT_MIN}
85 .\" shall be returned and a domain error shall occur.
86 .SH ERRORS
87 See
88 .BR math_error (7)
89 for information on how to determine whether an error has occurred
90 when calling these functions.
91 .PP
92 The following errors can occur:
93 .TP
94 Domain error: \fIx\fP is 0 or a NaN
95 An invalid floating-point exception
96 .RB ( FE_INVALID )
97 is raised, and
98 .I errno
99 is set to
100 .B EDOM
101 (but see BUGS).
102 .TP
103 Domain error: \fIx\fP is an infinity
104 An invalid floating-point exception
105 .RB ( FE_INVALID )
106 is raised, and
107 .I errno
108 is set to
109 .B EDOM
110 (but see BUGS).
111 .SH ATTRIBUTES
112 For an explanation of the terms used in this section, see
113 .BR attributes (7).
114 .ad l
115 .nh
116 .TS
117 allbox;
118 lbx lb lb
119 l l l.
120 Interface Attribute Value
121 T{
122 .BR ilogb (),
123 .BR ilogbf (),
124 .BR ilogbl ()
125 T} Thread safety MT-Safe
126 .TE
127 .hy
128 .ad
129 .sp 1
130 .SH STANDARDS
131 C11, POSIX.1-2008.
132 .SH HISTORY
133 C99, POSIX.1-2001.
134 .SH BUGS
135 .\" Bug raised: https://www.sourceware.org/bugzilla/show_bug.cgi?id=6794
136 Before glibc 2.16, the following bugs existed in the
137 glibc implementation of these functions:
138 .IP \[bu] 3
139 The domain error case where
140 .I x
141 is 0 or a NaN did not cause
142 .I errno
143 to be set or (on some architectures) raise a floating-point exception.
144 .IP \[bu]
145 The domain error case where
146 .I x
147 is an infinity did not cause
148 .I errno
149 to be set or raise a floating-point exception.
150 .SH SEE ALSO
151 .BR log (3),
152 .BR logb (3),
153 .BR significand (3)