| 1 |
'\" t |
| 2 |
.\" Copyright 2002, Walter Harms <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 6 |
.\" |
| 7 |
.TH isgreater 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
isgreater, isgreaterequal, isless, islessequal, islessgreater, |
| 10 |
isunordered \- floating-point relational tests without exception for NaN |
| 11 |
.SH LIBRARY |
| 12 |
Math library |
| 13 |
.RI ( libm ,\~ \-lm ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.B #include <math.h> |
| 17 |
.P |
| 18 |
.BI "int isgreater(" x ", " y ); |
| 19 |
.BI "int isgreaterequal(" x ", " y ); |
| 20 |
.BI "int isless(" x ", " y ); |
| 21 |
.BI "int islessequal(" x ", " y ); |
| 22 |
.BI "int islessgreater(" x ", " y ); |
| 23 |
.BI "int isunordered(" x ", " y ); |
| 24 |
.fi |
| 25 |
.P |
| 26 |
.RS -4 |
| 27 |
Feature Test Macro Requirements for glibc (see |
| 28 |
.BR feature_test_macros (7)): |
| 29 |
.RE |
| 30 |
.P |
| 31 |
.nf |
| 32 |
All functions described here: |
| 33 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 34 |
.fi |
| 35 |
.SH DESCRIPTION |
| 36 |
The normal relational operations (like |
| 37 |
.BR < , |
| 38 |
"less than") |
| 39 |
fail if one of the operands is NaN. |
| 40 |
This will cause an exception. |
| 41 |
To avoid this, C99 defines the macros listed below. |
| 42 |
.P |
| 43 |
These macros are guaranteed to evaluate their arguments only once. |
| 44 |
The arguments must be of real floating-point type (note: do not pass |
| 45 |
integer values as arguments to these macros, since the arguments will |
| 46 |
.I not |
| 47 |
be promoted to real-floating types). |
| 48 |
.TP |
| 49 |
.BR isgreater () |
| 50 |
determines |
| 51 |
.I (x)\ >\ (y) |
| 52 |
without an exception |
| 53 |
if |
| 54 |
.I x |
| 55 |
or |
| 56 |
.I y |
| 57 |
is NaN. |
| 58 |
.TP |
| 59 |
.BR isgreaterequal () |
| 60 |
determines |
| 61 |
.I (x)\ >=\ (y) |
| 62 |
without an exception |
| 63 |
if |
| 64 |
.I x |
| 65 |
or |
| 66 |
.I y |
| 67 |
is NaN. |
| 68 |
.TP |
| 69 |
.BR isless () |
| 70 |
determines |
| 71 |
.I (x)\ <\ (y) |
| 72 |
without an exception |
| 73 |
if |
| 74 |
.I x |
| 75 |
or |
| 76 |
.I y |
| 77 |
is NaN. |
| 78 |
.TP |
| 79 |
.BR islessequal () |
| 80 |
determines |
| 81 |
.I (x)\ <=\ (y) |
| 82 |
without an exception |
| 83 |
if |
| 84 |
.I x |
| 85 |
or |
| 86 |
.I y |
| 87 |
is NaN. |
| 88 |
.TP |
| 89 |
.BR islessgreater () |
| 90 |
determines |
| 91 |
.I (x)\ <\ (y)\ ||\ (x)\ >\ (y) |
| 92 |
without an exception if |
| 93 |
.I x |
| 94 |
or |
| 95 |
.I y |
| 96 |
is NaN. |
| 97 |
This macro is not equivalent to |
| 98 |
.I x\ !=\ y |
| 99 |
because that expression is |
| 100 |
true if |
| 101 |
.I x |
| 102 |
or |
| 103 |
.I y |
| 104 |
is NaN. |
| 105 |
.TP |
| 106 |
.BR isunordered () |
| 107 |
determines whether its arguments are unordered, that is, whether |
| 108 |
at least one of the arguments is a NaN. |
| 109 |
.SH RETURN VALUE |
| 110 |
The macros other than |
| 111 |
.BR isunordered () |
| 112 |
return the result of the relational comparison; |
| 113 |
these macros return 0 if either argument is a NaN. |
| 114 |
.P |
| 115 |
.BR isunordered () |
| 116 |
returns 1 if |
| 117 |
.I x |
| 118 |
or |
| 119 |
.I y |
| 120 |
is NaN and 0 otherwise. |
| 121 |
.SH ERRORS |
| 122 |
No errors occur. |
| 123 |
.SH ATTRIBUTES |
| 124 |
For an explanation of the terms used in this section, see |
| 125 |
.BR attributes (7). |
| 126 |
.TS |
| 127 |
allbox; |
| 128 |
lbx lb lb |
| 129 |
l l l. |
| 130 |
Interface Attribute Value |
| 131 |
T{ |
| 132 |
.na |
| 133 |
.nh |
| 134 |
.BR isgreater (), |
| 135 |
.BR isgreaterequal (), |
| 136 |
.BR isless (), |
| 137 |
.BR islessequal (), |
| 138 |
.BR islessgreater (), |
| 139 |
.BR isunordered () |
| 140 |
T} Thread safety MT-Safe |
| 141 |
.TE |
| 142 |
.SH VERSIONS |
| 143 |
Not all hardware supports these functions, |
| 144 |
and where hardware support isn't provided, they will be emulated by macros. |
| 145 |
This will result in a performance penalty. |
| 146 |
Don't use these functions if NaN is of no concern for you. |
| 147 |
.SH STANDARDS |
| 148 |
C11, POSIX.1-2008. |
| 149 |
.SH HISTORY |
| 150 |
POSIX.1-2001, C99. |
| 151 |
.SH SEE ALSO |
| 152 |
.BR fpclassify (3), |
| 153 |
.BR isnan (3) |