1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
1 |
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved |
2
by Francesco Paolo Lovergine
* Alligned to linux main manpages edition. |
2 |
.TH "ILOGB" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" |
1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
3 |
.\" ilogb |
4 |
.SH NAME |
|
5 |
ilogb, ilogbf, ilogbl \- return an unbiased exponent
|
|
6 |
.SH SYNOPSIS |
|
7 |
.LP
|
|
8 |
\fB#include <math.h>
|
|
9 |
.br
|
|
10 |
.sp
|
|
11 |
int ilogb(double\fP \fIx\fP\fB); |
|
12 |
.br
|
|
13 |
int ilogbf(float\fP \fIx\fP\fB); |
|
14 |
.br
|
|
15 |
int ilogbl(long double\fP \fIx\fP\fB); |
|
16 |
.br
|
|
17 |
\fP
|
|
18 |
.SH DESCRIPTION |
|
19 |
.LP
|
|
20 |
These functions shall return the exponent part of their argument \fIx\fP. |
|
21 |
Formally, the return value is the integral part of |
|
22 |
log_r|x| as a signed integral value, for non-zero \fIx\fP, where \fIr\fP |
|
23 |
is the radix of the machine's floating-point |
|
24 |
arithmetic, which is the value of FLT_RADIX defined in \fI<float.h>\fP. |
|
25 |
.LP
|
|
26 |
An application wishing to check for error situations should set \fIerrno\fP |
|
27 |
to zero and call |
|
28 |
\fIfeclearexcept\fP(FE_ALL_EXCEPT) before calling these functions. |
|
29 |
On return, if \fIerrno\fP is non-zero or |
|
30 |
\fIfetestexcept\fP(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) |
|
31 |
is non-zero, an error has occurred. |
|
32 |
.SH RETURN VALUE |
|
33 |
.LP
|
|
34 |
Upon successful completion, these functions shall return the exponent |
|
35 |
part of \fIx\fP as a signed integer value. They are |
|
36 |
equivalent to calling the corresponding \fIlogb\fP() function and |
|
37 |
casting the returned value |
|
38 |
to type \fBint\fP. |
|
39 |
.LP
|
|
40 |
If \fIx\fP is 0, \ a domain error shall occur, and |
|
41 |
the value FP_ILOGB0 shall be returned. |
|
42 |
.LP
|
|
43 |
If \fIx\fP is \(+-Inf, \ a domain error shall occur, and |
|
44 |
the value {INT_MAX} shall be returned. |
|
45 |
.LP
|
|
46 |
If \fIx\fP is a NaN, \ a domain error shall occur, and |
|
47 |
the value FP_ILOGBNAN shall be returned. |
|
48 |
.LP
|
|
49 |
If the correct value is greater than {INT_MAX}, {INT_MAX} shall be |
|
50 |
returned and a domain error shall occur. |
|
51 |
.LP
|
|
52 |
If the correct value is less than {INT_MIN}, {INT_MIN} shall be returned |
|
53 |
and a domain error shall occur. |
|
54 |
.SH ERRORS |
|
55 |
.LP
|
|
56 |
These functions shall fail if: |
|
57 |
.TP 7 |
|
58 |
Domain\ Error
|
|
59 |
The \fIx\fP argument is zero, NaN, or \(+-Inf, or the correct value |
|
60 |
is not representable as an integer. |
|
61 |
.LP
|
|
62 |
If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, |
|
63 |
then \fIerrno\fP shall be set to [EDOM]. If the |
|
64 |
integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, |
|
65 |
then the invalid floating-point exception shall be raised. |
|
66 |
.sp
|
|
67 |
.LP
|
|
68 |
\fIThe following sections are informative.\fP |
|
69 |
.SH EXAMPLES |
|
70 |
.LP
|
|
71 |
None. |
|
72 |
.SH APPLICATION USAGE |
|
73 |
.LP
|
|
74 |
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling |
|
75 |
& MATH_ERREXCEPT) are independent of |
|
76 |
each other, but at least one of them must be non-zero. |
|
77 |
.SH RATIONALE |
|
78 |
.LP
|
|
79 |
The errors come from taking the expected floating-point value and |
|
80 |
converting it to \fBint\fP, which is an invalid operation in |
|
81 |
IEEE\ Std\ 754-1985 (since overflow, infinity, and NaN are not representable |
|
82 |
in a type \fBint\fP), so should be a domain |
|
83 |
error. |
|
84 |
.LP
|
|
85 |
There are no known implementations that overflow. For overflow to |
|
86 |
happen, {INT_MAX} must be less than |
|
87 |
LDBL_MAX_EXP*\fIlog2\fP(FLT_RADIX) or {INT_MIN} must be greater than |
|
88 |
LDBL_MIN_EXP*\fIlog2\fP(FLT_RADIX) if subnormals are not |
|
89 |
supported, or {INT_MIN} must be greater than (LDBL_MIN_EXP-LDBL_MANT_DIG)*\fIlog2\fP(FLT_RADIX) |
|
90 |
if subnormals are supported. |
|
91 |
.SH FUTURE DIRECTIONS |
|
92 |
.LP
|
|
93 |
None. |
|
94 |
.SH SEE ALSO |
|
95 |
.LP
|
|
96 |
\fIfeclearexcept\fP() , \fIfetestexcept\fP() , \fIlogb\fP() , \fIscalb\fP() |
|
97 |
, the Base Definitions volume of |
|
98 |
IEEE\ Std\ 1003.1-2001, Section 4.18, Treatment of Error Conditions |
|
99 |
for |
|
100 |
Mathematical Functions, \fI<float.h>\fP, \fI<math.h>\fP |
|
101 |
.SH COPYRIGHT |
|
102 |
Portions of this text are reprinted and reproduced in electronic form |
|
103 |
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology |
|
104 |
-- Portable Operating System Interface (POSIX), The Open Group Base |
|
105 |
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of |
|
106 |
Electrical and Electronics Engineers, Inc and The Open Group. In the |
|
107 |
event of any discrepancy between this version and the original IEEE and |
|
108 |
The Open Group Standard, the original IEEE and The Open Group Standard |
|
109 |
is the referee document. The original Standard can be obtained online at |
|
110 |
http://www.opengroup.org/unix/online.html . |