HP-UX Floating-Point Guide
Chapter 2 63
Floating-Point Principles and the IEEE Standard for Binary Floating-Point Arithmetic
Floating-Point Operations
NOTE The assertion operators should not be confused with actual programming
language operators. Languages, for example, do not support the ?
operator.
At Release 11.0, the C math library provides six new macros that
implement comparison operations without raising exceptions:
isgreater, isgreaterequal, isless, islessequal,
islessgreater, and unordered. See “C9X Functions and Macros” on
page 119 for details.
An assertion may also be negated.
The IEEE standard defines two versions of every possible assertion: the
aware and the non-aware version. Both the aware and non-aware
versions of an assertion treat a NaN as a special value that compares as
neither less than nor greater than any numeric value, and as unequal to
any value, including any other NaN and even itself. This definition yields
the interesting fact that the assertion “x = x” will evaluate to FALSE if x
is a NaN. In fact, applications sometimes use this comparison operation
specifically to detect NaNs, although it is a dangerous practice because
some vendors’ optimizers remove this operation from the code.
The non-aware version of an assertion behaves the same as the aware
version, with the addition that if either or both operands is a NaN, it also
raises an invalid operation exception for the <, <=, >, and >= assertions.
The =, !=, and ? assertions are the only ones that are valid with NaN
operands.
Signaling NaNs cause an invalid operation exception for both aware and
non-aware assertions.
The behavior of the comparison operation for each of the possible
operand kinds is as follows:
Normalized
and
Denormalized
Values The operands are algebraically compared.
Zero Zeros are greater than any nonzero negative value and
less than any nonzero positive value. The sign of a zero
is ignored, so that two zeros always compare as equal
even if they have opposite signs.