finite(3)

πŸ’– finite(3) β€” the BSD float-classification girlies πŸ’–

okay bestie, pull up a chair, we're doing finite(3) from the Library Functions Manual today and honestly? it's giving "legacy but iconic". πŸŽ€


✨ NAME ✨

finite, finitef, finitel, isinf, isinff, isinfl, isnan, isnanf, isnanl β€” the BSD floating-point classification functions. that's the whole squad. 🫢


πŸ“š LIBRARY πŸ“š

Math library, aka libm, aka you link it with -lm. don't forget her. she WILL ghost you if you forget her. πŸ’…

-lm

🌸 SYNOPSIS 🌸

first things first, you gotta include the header:

#include <math.h>

then here's the whole friend group, all typed out:

int finite(double x);
int finitef(float x);
int finitel(long double x);

int isinf(double x);
int isinff(float x);
int isinfl(long double x);

int isnan(double x);
int isnanf(float x);
int isnanl(long double x);

🧚 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

okay so this is the part where glibc makes you prove you're allowed to use these. rude? yes. necessary? also yes. here's exactly what you need, no cap:

finite(), finitef(), finitel():
    /* glibc >= 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

isinf():
    _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
        || /* glibc >= 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

isinff(), isinfl():
    /* glibc >= 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

isnan():
    _XOPEN_SOURCE || _ISOC99_SOURCE
        || /* glibc >= 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

isnanf(), isnanl():
    _XOPEN_SOURCE >= 600
        || /* glibc >= 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

πŸ”₯ DESCRIPTION πŸ”₯

so what do these actually do? lemme break it down, bestie, one function family at a time.

  • finite(), finitef(), finitel() β€” these return a nonzero value if x is neither infinite nor a "not-a-number" (NaN) value, and 0 otherwise. so basically: "is this number a normal, well-adjusted member of society?" yes β†’ nonzero. no β†’ 0. πŸ’–
  • isnan(), isnanf(), isnanl() β€” these return a nonzero value if x is a NaN value, and 0 otherwise. the detector for when your math went completely off the rails. 😭
  • isinf(), isinff(), isinfl() β€” these return 1 if x is positive infinity, -1 if x is negative infinity, and 0 otherwise. three possible answers, not just two β€” she's nuanced. πŸ‘‘

πŸ¦‹ ATTRIBUTES πŸ¦‹

for the whole "what do these terms even mean" situation, go peek at attributes(7). the original prints this as a table, but tables don't exist in our group chat so here it is as a vibe:

  • Interface: finite(), finitef(), finitel(), isinf(), isinff(), isinfl(), isnan(), isnanf(), isnanl()
  • Attribute: Thread safety
  • Value: MT-Safe

so yeah β€” all nine of them are MT-Safe, every single one, no exceptions. 🫢


⚠️ NOTES ⚠️

okay so this is the part where I have to be real with you:

these functions are obsolete. like, deprecated-era. C99 defines the macros isfinite(), isinf(), and isnan() (for all types) and those are what replaced them. πŸ’€

and there's more β€” the C99 isinf() has weaker guarantees on the return value than the one you're reading about right now. so heads up on that.

go read fpclassify(3) for the full tea. 🌸


⭐ SEE ALSO ⭐


so that's finite(3)! iconic, a little vintage, still lives in libm rent-free. go forth and classify your floats, bestie πŸ’…βœ¨

this page was rocking Linux man-pages 6.20, dated 2026-02-08 β€” ty for coming to my TED talk, 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