Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upstd::cmp::max vs std::num::Float vs NaN #852
Comments
steveklabnik
referenced this issue
Feb 15, 2015
Closed
std::cmp::max vs std::num::Float vs NaN #21816
steveklabnik
added
the
A-libs
label
Feb 15, 2015
This comment has been minimized.
This comment has been minimized.
|
I stumbled upon this issue after reading a comment from HN (which was posted by the issue author, by the way). While I'm more inclined to not have Regarding the documentation concerns, rust-lang/rust#25951 made it clear how Also reading rust-lang/rust#25663, @alexcrichton said that |
glaebhoerl
referenced this issue
Aug 12, 2015
Open
Wrapper newtypes for f32 and f64 implementing Ord #1249
This comment has been minimized.
This comment has been minimized.
xaviershay
commented
Sep 26, 2015
|
I was confused by this. It's not immediately obvious why |
This comment has been minimized.
This comment has been minimized.
xaviershay
commented
Sep 26, 2015
|
|
petrochenkov
added
T-libs
and removed
A-libs
labels
Jan 28, 2018
This comment has been minimized.
This comment has been minimized.
|
I'm going to deem this resolved with the addition of Feel free to comment or reopen if you disagree. |
steveklabnik commentedFeb 15, 2015
Saturday Jan 31, 2015 at 18:28 GMT
For earlier discussion, see rust-lang/rust#21816
This issue was labelled with: A-libs in the Rust repository
It's werid that
std::cmp::maxcan't comparef64numbers. I know that strictly speaking IEEE floats don't have total order this function expects, but still it's surprising (andpartial_maxis awkward to use).And there's
std::num::Float::maxwhich works withf64just fine (the docs don't even say howNaNis handled).It bugs me that the two versions of
maxare not consistent in their strictness, and that the first-and-most-obviousmaxfunction in the stdlib "doesn't work" with a basic type in the language.My suggestion:
maxversion that only allowsOrdto something else, liketotal_maxorstrict_max.std::cmp::maxfor floating point numbers, so thata.max(b)is consistent withmax(a,b).