add correct floating point min and max methods.
The `std::cmp` functions are not correct for floating point types. `min(NaN, 2.0)` and `min(2.0, NaN)` return different values, because these functions assume a total order. Floating point types need special `min`, `max` and `clamp` functions.
This commit is contained in:
@@ -313,6 +313,9 @@ pub enum FPCategory {
|
||||
pub trait Float: Signed
|
||||
+ Round
|
||||
+ Primitive {
|
||||
fn max(self, other: Self) -> Self;
|
||||
fn min(self, other: Self) -> Self;
|
||||
|
||||
// FIXME (#5527): These should be associated constants
|
||||
fn nan() -> Self;
|
||||
fn infinity() -> Self;
|
||||
|
||||
Reference in New Issue
Block a user