Correctness of binary comparisons #
The format-parameterized executable comparison agrees with exact dyadic, real, and extended-real
order. The selection theorems also specify IEEE minimum and maximum, including infinities
and signed-zero tie breaking.
All results are uniform in the binary format.
Classification helpers #
NaN selection returns none when both inputs are known not to be NaNs.
A signaling left operand has first priority in minNum and is returned after quieting.
When both operands are quiet NaNs, minNum quiets and returns the left operand.
A signaling left operand has first priority in maxNum and is returned after quieting.
When both operands are quiet NaNs, maxNum quiets and returns the left operand.
IEEE 754-2019 minimumNumber and maximumNumber #
Without NaNs, minimumNumber is exactly the IEEE minimum operation.
Without NaNs, maximumNumber is exactly the IEEE maximum operation.
minimumNumber returns the right operand whenever only the left operand is a NaN, even a
signaling one. This is the point where IEEE 754-2019 departs from minNum.
minimumNumber returns the left operand whenever only the right operand is a NaN.
When both operands are NaNs, minimumNumber delivers the quiet NaN chosen by bothNaNNumber.
maximumNumber returns the right operand whenever only the left operand is a NaN.
maximumNumber returns the left operand whenever only the right operand is a NaN.
When both operands are NaNs, maximumNumber delivers the quiet NaN chosen by bothNaNNumber.
The NaN chosen for two NaN operands is always one of them, quieted.
When neither operand is a signaling NaN, minimumNumber agrees with minNum, including when
one or both operands are quiet NaNs.
The maximumNumber counterpart of minimumNumber_eq_minNum_of_not_isSNaN.
The real interpretation erases the sign of an executable zero.
Non-NaN minimum and maximum #
minimumNumber never returns a NaN unless both operands are NaNs.
maximumNumber never returns a NaN unless both operands are NaNs.
Finite comparison #
Once both operands are known not to be NaNs, the public comparison is exactly the total non-NaN comparison.
Any successful public comparison determines the result of the total non-NaN comparison.
This is the proof bridge used by the min/max semantics below: runtime code does not need an unreachable unordered branch once NaNs have already been excluded.
When both operands decode to dyadics, executable comparison returns their exact dyadic ordering.
Finite executable comparison returns .lt exactly when the decoded reals are ordered.
Finite executable comparison returns .eq exactly when the decoded reals are equal.
Finite executable comparison returns .gt exactly when the decoded reals are reversed.
On finite inputs, executable comparison agrees with strict real order.
On finite inputs, executable comparison agrees with real equality.
On finite inputs, executable comparison agrees with reversed strict real order.
Signed-zero tie breaking #
Positive and policy-selected negative zero compare equal numerically.
minimum selects policy-negative zero from a positive-zero/negative-zero tie.
In a format without signed zero, both inputs and the result are the single positive zero.
maximum selects positive zero from a positive-zero/negative-zero tie.
In a format without signed zero, both inputs already denote the single positive zero.
For every encoding with signed zero, minimum (+0, -0) returns the negative zero encoding.
For every encoding with signed zero, maximum (+0, -0) returns the positive zero encoding.
For every encoding with signed zero, minNum (+0, -0) returns the negative zero encoding.
For every encoding with signed zero, maxNum (+0, -0) returns the positive zero encoding.
For every encoding with signed zero, minimumNumber (+0, -0) returns the negative zero encoding.
For every encoding with signed zero, maximumNumber (+0, -0) returns the positive zero encoding.
Finite minimum and maximum #
On finite inputs, IEEE minimum agrees with real min.
On finite inputs, IEEE maximum agrees with real max.
Extended-real comparison #
Every successful extended-real interpretation is either a signed infinity or a finite real value.
A non-NaN comparison returns the ordering of its exact extended-real values.
Non-NaN executable comparison agrees with strict extended-real order.
Non-NaN executable comparison agrees with extended-real equality.
Every non-NaN value compares equal to itself.
Non-NaN executable comparison agrees with reversed strict extended-real order.
Extended-real minimum and maximum #
The total extended-real interpretation erases the sign of an executable zero.
On non-NaN values, minNum has the exact extended-real semantics of mathematical minimum.
Signed-zero tie breaking remains visible in the encoded result even though toEReal identifies
the two zeros.
On non-NaN values, maxNum has the exact extended-real semantics of mathematical maximum.
Signed-zero tie breaking remains visible in the encoded result even though toEReal identifies
the two zeros.
On non-NaN values, minimumNumber has the extended-real semantics of mathematical minimum.
On non-NaN values, maximumNumber has the extended-real semantics of mathematical maximum.
minimumNumber is commutative up to extended-real value on non-NaN operands. This interpretation
identifies the two signed zeros.
The maximumNumber counterpart of toEReal_minimumNumber_comm.