CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 22 Jul 2025 19:29:47 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/cmath/ilogb/
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 22 Jul 2025 19:29:47 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"a685-nVxgRhMHaEZhwgwyki/8JNGTpz4"
Content-Encoding: gzip
Returns the integral part of the logarithm of |x|, using FLT_RADIX as base for the logarithm.
This is the exponent used internally by the machine to express the floating-point value x, when it uses a significand between
x = significand * FLT_RADIX exponent
Generally, FLT_RADIX is
Two specific macro constants may be returned by this function to indicate the following special cases:
These macro constants are defined in this same header (<cmath>).
If x is subnormal, the value returned is the one corresponding to the normalized representation (negative exponent).
If x is zero, it returns FP_LOGB0 (a special value, only returned by this function, defined in <cmath>).
If x is infinite, it returns INT_MAX.
If x is NaN, it returns FP_ILOGBNAN (a special value, only returned by this function, defined in <cmath>).
If the magnitude of the result is too large to be represented by a value of the return type, the function returns an unspecified value, and an overflow range error occurs.
A zero, infinite or NaN value of x may also cause either a domain error or an overflow range error.
If an domain error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to EDOM.
- And math_errhandling has MATH_ERREXCEPT set: FE_INVALID is raised.
If an overflow range error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: FE_OVERFLOW is raised.
Output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<cmath> (math.h)
functions
- abs
- acos
-
acoshC++11
- asin
-
asinhC++11
- atan
- atan2
-
atanhC++11
-
cbrtC++11
- ceil
-
copysignC++11
- cos
- cosh
-
erfC++11
-
erfcC++11
- exp
-
exp2C++11
-
expm1C++11
- fabs
-
fdimC++11
- floor
-
fmaC++11
-
fmaxC++11
-
fminC++11
- fmod
-
fpclassifyC++11
- frexp
-
hypotC++11
-
ilogbC++11
-
isfiniteC++11
-
isgreaterC++11
-
isgreaterequalC++11
-
isinfC++11
-
islessC++11
-
islessequalC++11
-
islessgreaterC++11
-
isnanC++11
-
isnormalC++11
-
isunorderedC++11
- ldexp
-
lgammaC++11
-
llrintC++11
-
llroundC++11
- log
- log10
-
log1pC++11
-
log2C++11
-
logbC++11
-
lrintC++11
-
lroundC++11
- modf
-
nanC++11
-
nanfC++11
-
nanlC++11
-
nearbyintC++11
-
nextafterC++11
-
nexttowardC++11
- pow
-
remainderC++11
-
remquoC++11
-
rintC++11
-
roundC++11
-
scalblnC++11
-
scalbnC++11
-
signbitC++11
- sin
- sinh
- sqrt
- tan
- tanh
-
tgammaC++11
-
truncC++11
macro constants
types
function
<cmath> <ctgmath>
ilogb
int ilogb (double x);int ilogbf (float x);int ilogbl (long double x);
int ilogb (double x);int ilogb (float x);int ilogb (long double x);int ilogb (T x); // additional overloads for integral types
Integer binary logarithm
This is the exponent used internally by the machine to express the floating-point value x, when it uses a significand between
1.0
and FLT_RADIX, so that, for a positive x:x = significand * FLT_RADIX exponent
Generally, FLT_RADIX is
2
, and the value returned by this function is one less than the exponent obtained with frexp (because of the different significand normalization as [1.0,2.0)
instead of [0.5,1.0)
).
Header <tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (
<cmath>
) for the integral types: These overloads effectively cast x to a double
before calculations (defined for T being any integral type).Two specific macro constants may be returned by this function to indicate the following special cases:
macro | description |
---|---|
FP_ILOGB0 | x is zero |
FP_ILOGBNAN | x is NaN |
These macro constants are defined in this same header (<cmath>).
Parameters
- x
- Value whose ilogb is returned.
Return Value
If x is normal, the base-FLT_RADIX logarithm of x.If x is subnormal, the value returned is the one corresponding to the normalized representation (negative exponent).
If x is zero, it returns FP_LOGB0 (a special value, only returned by this function, defined in <cmath>).
If x is infinite, it returns INT_MAX.
If x is NaN, it returns FP_ILOGBNAN (a special value, only returned by this function, defined in <cmath>).
If the magnitude of the result is too large to be represented by a value of the return type, the function returns an unspecified value, and an overflow range error occurs.
A zero, infinite or NaN value of x may also cause either a domain error or an overflow range error.
If an domain error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to EDOM.
- And math_errhandling has MATH_ERREXCEPT set: FE_INVALID is raised.
If an overflow range error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: FE_OVERFLOW is raised.
Example
|
|
Output:
ilogb(10.000000) = 3 |
See also
- logb
- Compute floating-point base logarithm (function)
- log2
- Compute binary logarithm (function)
- pow
- Raise to power (function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us