ilogb(3)
π ilogb(3) β ur fave exponent-extractor, bestie β¨
okay so like. this is the manual page for ilogb, ilogbf and ilogbl from the Library Functions Manual, and no cap it's lowkey the most useful lil trio in libm. sit down, grab a boba, we're gonna get into it π§π¦
πΈ NAME πΈ
ilogb, ilogbf, ilogbl β get integer exponent of a floating-point value
like. that's it. that's the whole job. and she EATS every single time π
π LIBRARY π
Math library (libm, -lm)
bestie if ur link line doesn't have -lm ur not gonna have a good time. just saying π«Ά
β¨ SYNOPSIS β¨
#include <math.h>
int ilogb(double x);
int ilogbf(float x);
int ilogbl(long double x);
π Feature Test Macro Requirements for glibc π
(kinda iconic that u even have to ask, but see feature_test_macros(7))
ilogb():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| _XOPEN_SOURCE >= 500
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
ilogbf(), ilogbl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
π DESCRIPTION π
These functions return the exponent part of their argument as a signed integer. literally just the exponent. as an int. that's the vibe.
When no error occurs, these functions are equivalent to the corresponding logb(3) functions, cast to int. so like, same energy as logb(3), just squeezed into an int bestie π
π RETURN VALUE π
On success, these functions return the exponent of x, as a signed integer. slay π
But ok here's where it gets spicy, pay attention:
- If x is zero, then a domain error occurs, and the functions return
FP_ILOGB0. - If x is a NaN, then a domain error occurs, and the functions return
FP_ILOGBNAN. - If x is negative infinity or positive infinity, then a domain error occurs, and the functions return
INT_MAX.
so like. three whole separate chaos modes. noted. π
π¨ ERRORS π¨
See math_error(7) for information on how to determine whether an error has occurred when calling these functions. (that's the bestie u call when u need to know if something went wrong fr fr)
The following errors can occur:
- Domain error: x is 0 or a NaN β An invalid floating-point exception (
FE_INVALID) is raised, anderrnois set toEDOM(but see BUGS). - Domain error: x is an infinity β An invalid floating-point exception (
FE_INVALID) is raised, anderrnois set toEDOM(but see BUGS).
π«£ both of those have a lil "(but see BUGS)" attached and honestly? the BUGS section is right down there, go look, i'm not gatekeeping.
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
ilogb(),ilogbf(),ilogbl() - Attribute: Thread safety
- Value:
MT-Safe
MT-Safe and unbothered. main character energy, no notes π§
β STANDARDS β
C11, POSIX.1-2008. periodt. π
π°οΈ HISTORY π°οΈ
C99, POSIX.1-2001. she's been around. a whole legacy icon π
π BUGS π
Before glibc 2.16, the following bugs existed in the glibc implementation of these functions:
- The domain error case where x is 0 or a NaN did not cause
errnoto be set or (on some architectures) raise a floating-point exception. - The domain error case where x is an infinity did not cause
errnoto be set or raise a floating-point exception.
π not the silent failures. if ur on ancient glibc, just know the error reporting was giving nothing. detected: zero. screamed: also zero π
π SEE ALSO π
log(3), logb(3), significand(3)
and that's the whole page bestie!! this lil masterpiece of a man page came to u from Linux man-pages 6.20, dated 2026-02-08, under the name ilogb(3) πβ¨ go forth and extract exponents responsibly, ily, mwah ππ¦
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2004, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms