[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
totalorder specification
From: |
Bruno Haible |
Subject: |
totalorder specification |
Date: |
Sat, 07 Oct 2023 13:51:32 +0200 |
There is a summarizing specification in the glibc manual:
https://www.gnu.org/software/libc/manual/html_node/FP-Comparison-Functions.html
The ISO C 23 standard § F.10.12.1 has a summary as well:
2 Description
The totalorder functions determine whether the total order relationship,
defined by IEC 60559, is true for the ordered pair of *x, *y. These
functions are fully specified in IEC 60559. These functions are
independent of the current rounding direction mode and raise no
floating-point exceptions, even if *x or *y is a signaling NaN.
3 Returns
The totalorder functions return nonzero if and only if the total order
relation is true for the ordered pair of *x, *y.
IEC 60559 is said to be identical to IEEE 754-2008 (says Wikipedia
<https://en.wikipedia.org/wiki/IEEE_754>), and IEEE 754-2008 has this text (from
<https://gist.github.com/leto/176888/e1bf1cf76d56a3da34b6be5a0f6b95139a747299>):
7.10 Details of totalOrder predicate
7.10.0
For each supported non-storage floating-point format, an implementation
shall provide certain predicates that define orderings among all operands
in a particular format.
totalOrder(x,y) imposes a total ordering on canonical members of the
format of x and y;
a) if x < y, totalOrder(x, y) is true
b) if x > y, totalOrder(x, y) is false
c) if x = y:
1) totalOrder(−0, +0) is true
2) totalOrder(+0, −0) is false
3) if x and y represent the same floating-point datum:
i) if x and y have negative sign,
totalOrder(x, y) is true if and only if the
exponent of x ≥ the exponent of y
ii) otherwise
totalOrder(x, y) is true if and only if the
exponent of x ≤ the exponent of y
Note that totalOrder does not impose a total ordering on all
encodings in a format. In particular it does not distinguish
among different encodings of the same floating-point representation,
as when one or both encodings are non-canonical.
d) if x and y are unordered numerically because x or y is NaN:
1) totalOrder(−NaN, y) is true where −NaN represents a NaN with
negative sign bit and y is a floating-point number.
2) totalOrder(x, +NaN) is true where +NaN represents a NaN with
positive sign bit and x is a floating-point number.
3) if x and y are both NaNs, then totalOrder reflects a total
ordering based on
i) negative sign bit < positive sign bit
ii) signaling < quiet for +NaN, reverse for −NaN
iii) lesser payload < greater payload for +NaN, reverse for −NaN
Neither signaling nor quiet NaNs signal an exception.
For canonical x and y, totalOrder(x,y) and totalOrder(y,x) are both true
only if x and y are bitwise identical.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- totalorder specification,
Bruno Haible <=