Trait TotalOrder
trait TotalOrder
Trait for floating point numbers that provide an implementation
of the totalOrder predicate as defined in the IEEE 754 (2008 revision)
floating point standard.
Required Methods
fn total_cmp(self: &Self, other: &Self) -> OrderingReturn the ordering between
selfandother.Unlike the standard partial comparison between floating point numbers, this comparison always produces an ordering in accordance to the
totalOrderpredicate as defined in the IEEE 754 (2008 revision) floating point standard. The values are ordered in the following sequence:- negative quiet NaN
- negative signaling NaN
- negative infinity
- negative numbers
- negative subnormal numbers
- negative zero
- positive zero
- positive subnormal numbers
- positive numbers
- positive infinity
- positive signaling NaN
- positive quiet NaN.
The ordering established by this function does not always agree with the
PartialOrdandPartialEqimplementations. For example, they consider negative and positive zero equal, whiletotal_cmpdoesn't.The interpretation of the signaling NaN bit follows the definition in the IEEE 754 standard, which may not match the interpretation by some of the older, non-conformant (e.g. MIPS) hardware implementations.
Examples
use TotalOrder; use Ordering; use ; check_eq; check_eq; check_lt; check_lt; check_lt;
Implementors
impl TotalOrder for f64impl TotalOrder for f32