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, and errno is set to EDOM (but see BUGS).
  • Domain error: x is an infinity β€” An invalid floating-point exception (FE_INVALID) is raised, and errno is set to EDOM (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 errno to be set or (on some architectures) raise a floating-point exception.
  • The domain error case where x is an infinity did not cause errno to 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms