isgreater(3)
π isgreater(3) β floating-point relational tests, but make it NaN-safe π
okay bestie, so this is a page from the Library Functions Manual, and it's about a lil family of macros that do comparisons without having a meltdown when NaN shows up π
β¨ NAME β¨
isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered β floating-point relational tests without exception for NaN π¦
π LIBRARY π
Math library (libm, -lm) β yeah you gotta link it, that's just the vibe.
πΈ SYNOPSIS πΈ
#include <math.h>
int isgreater(x, y);
int isgreaterequal(x, y);
int isless(x, y);
int islessequal(x, y);
int islessgreater(x, y);
int isunordered(x, y);
π Feature Test Macro Requirements for glibc (see feature_test_macros(7)): π
All functions described here:
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
π DESCRIPTION π
ok so here's the tea β β the normal relational operations (like <, that's "less than") literally fail if one of the operands is NaN. and not in a cute way, it causes an exception. so to dodge all that drama, C99 defines the macros listed below. era-defining honestly β¨
these macros are guaranteed to evaluate their arguments only once. and the arguments must be of real floating-point type. quick PSA: do NOT pass integer values as arguments to these macros, because the arguments will not be promoted to real-floating types. not me warning you twice, but like, i'm warning you twice π
isgreater()β figures out(x) > (y)without an exception ifxoryis NaN.isgreaterequal()β figures out(x) >= (y)without an exception ifxoryis NaN.isless()β figures out(x) < (y)without an exception ifxoryis NaN.islessequal()β figures out(x) <= (y)without an exception ifxoryis NaN.islessgreater()β figures out(x) < (y) || (x) > (y)without an exception ifxoryis NaN. β οΈ and this macro is not equivalent tox != y, because that expression is true ifxoryis NaN. so like, don't try that shortcut bestie, it's giving wrong answers πisunordered()β figures out whether its arguments are unordered, which is just a fancy way of saying: is at least one of the arguments a NaN? π§
π« RETURN VALUE π«
every macro except isunordered() returns the result of the relational comparison. and those macros return 0 if either argument is a NaN. (yeah, NaN just kills the whole comparison, that's the point.)
isunordered() returns 1 if x or y is NaN, and 0 otherwise. simple. iconic. slay π
π ERRORS π
No errors occur. literally none. that's the entire flex of this page, no cap. β¨
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
- Interface:
isgreater(),isgreaterequal(),isless(),islessequal(),islessgreater(),isunordered()- Attribute: Thread safety
- Value:
MT-Safeπ
so yeah, all of them are MT-Safe. go wild with your threads, it's fine π«Ά
π¦ VERSIONS π¦
not all hardware supports these functions, and where hardware support isn't provided, they'll be emulated by macros instead. and that comes with a performance penalty π.
don't use these functions if NaN is of no concern for you. fr fr, if you don't care about NaN, you're just paying the vibe tax for nothing.
β STANDARDS β
C11, POSIX.1-2008.
πΈ HISTORY πΈ
POSIX.1-2001, C99.
π SEE ALSO π
and that's the whole page, bestie! this was isgreater(3) from Linux man-pages 6.20, dated 2026-02-08 β go forth and compare floats without fear of exceptions πβ¨π¦π
π¦ 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