fpclassify(3)

โœจ fpclassify(3) โœจ

okay bestie, so this is the library functions manual page for fpclassify(3) and friends, and honestly? it's giving "float math but make it cute". we're in the libm zone and we're about to find out what kind of vibe your floating-point number is giving ๐Ÿ’…


๐ŸŽ€ NAME ๐ŸŽ€

fpclassify, isfinite, isnormal, isnan, isinf โ€” floating-point classification macros

like, five little macros whose entire job is answering "what even is this number" ๐Ÿ”


๐Ÿ“š LIBRARY ๐Ÿ“š

Math library (libm, -lm)

girl you literally have to link it. -lm. don't forget. i'm not gonna say it again. okay i will. -lm. ๐Ÿซถ

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <math.h>

int fpclassify(x);
int isfinite(x);
int isnormal(x);
int isnan(x);
int isinf(x);

๐Ÿ’ซ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): ๐Ÿ’ซ

ok so before any of these will show up you gotta define the right macro, otherwise glibc is gonna pretend it doesn't know you ๐Ÿ™ˆ here's the whole list, no skips:

  • fpclassify(), isfinite(), isnormal():
    • _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
  • isnan():
    • _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
    • || _XOPEN_SOURCE
    • || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    • || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
  • isinf():
    • _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
    • || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    • || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

๐ŸŒธ DESCRIPTION ๐ŸŒธ

Floating point numbers can have special values, such as infinite or NaN. yes bestie, numbers can be weird. not all floats are chill normal floats โ€” some of them are out here living their own life ๐Ÿ’€

With the macro fpclassify(x) you can find out what type x is. The macro takes any floating-point expression as argument. The result is one of the following values:

  • FP_NAN โ€” x is "Not a Number". (yes it's literally called that. iconic naming honestly.)
  • FP_INFINITE โ€” x is either positive infinity or negative infinity.
  • FP_ZERO โ€” x is zero. just vibing at the origin โœจ
  • FP_SUBNORMAL โ€” x is too small to be represented in normalized format. tiny little guy ๐Ÿฅบ
  • FP_NORMAL โ€” if nothing of the above is correct then it must be a normal floating-point number. the main character of the float world ๐Ÿ‘‘

The other macros provide a short answer to some standard questions. like a rapid-fire Q&A, group chat style ๐Ÿ“ฑ

  • isfinite(x) โ€” returns a nonzero value if (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
  • isnormal(x) โ€” returns a nonzero value if (fpclassify(x) == FP_NORMAL)
  • isnan(x) โ€” returns a nonzero value if (fpclassify(x) == FP_NAN)
  • isinf(x) โ€” returns 1 if x is positive infinity, and -1 if x is negative infinity.

๐Ÿ’… ATTRIBUTES ๐Ÿ’…

For an explanation of the terms used in this section, see attributes(7).

ok so the table got eaten by the vibe check, but here's what it said, i promise i'm not gatekeeping:

  • Interface: fpclassify(), isfinite(), isnormal(), isnan(), isinf()
  • Attribute: Thread safety
  • Value: MT-Safe

like all five of them, safe to use from multiple threads, no cap ๐Ÿงตโœจ


โญ STANDARDS โญ

C11, POSIX.1-2008.

so yes it's officially official. certified. periodt. ๐Ÿ‘‘


๐ŸŒˆ HISTORY ๐ŸŒˆ

POSIX.1-2001, C99.

In glibc 2.01 and earlier, isinf() returns a nonzero value (actually: 1) if x is positive infinity or negative infinity. (This is all that C99 requires.)

so basically old glibc wasn't out here distinguishing +inf from -inf, it just went "yep that's infinite alright" ๐Ÿซ  which, technically, is all C99 asked for. the bar was on the floor bestie.

๐Ÿ“ NOTES ๐Ÿ“

For isinf(), the standards merely say that the return value is nonzero if and only if the argument has an infinite value.

that's it. that's the whole requirement. no direction, no signs, just "is it infinite or nah" ๐Ÿ™ˆ


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ


and that's the whole page bestie ๐Ÿ’– this was Linux man-pages 6.20, dated 2026-02-08 โ€” go forth and classify your floats, you absolute icon, and remember to link -lm ๐ŸŽ€๐Ÿฆ‹โœจ

๐Ÿ“ฆ 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: GPL-1.0-or-later
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms