diff --git a/crates/bevy_utils/src/float_ord.rs b/crates/bevy_utils/src/float_ord.rs index 45832198ad..9e7931d220 100644 --- a/crates/bevy_utils/src/float_ord.rs +++ b/crates/bevy_utils/src/float_ord.rs @@ -4,9 +4,15 @@ use std::{ ops::Neg, }; -/// A wrapper type that enables ordering floats. This is a work around for the famous "rust float -/// ordering" problem. By using it, you acknowledge that sorting NaN is undefined according to spec. -/// This implementation treats NaN as the "smallest" float. +/// A wrapper for floats that implements [`Ord`], [`Eq`], and [`Hash`] traits. +/// +/// This is a work around for the fact that the IEEE 754-2008 standard, +/// implemented by Rust's [`f32`] type, +/// doesn't define an ordering for [`NaN`](f32::NAN), +/// and `NaN` is not considered equal to any other `NaN`. +/// +/// Wrapping a float with `FloatOrd` breaks conformance with the standard +/// by sorting `NaN` as less than all other numbers and equal to any other `NaN`. #[derive(Debug, Copy, Clone, PartialOrd)] pub struct FloatOrd(pub f32);