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โxis "Not a Number". (yes it's literally called that. iconic naming honestly.)FP_INFINITEโxis either positive infinity or negative infinity.FP_ZEROโxis zero. just vibing at the origin โจFP_SUBNORMALโxis 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)โ returns1ifxis positive infinity, and-1ifxis 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
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms