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