-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::cmp::max vs std::num::Float vs NaN #852
Comments
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 |
I was confused by this. It's not immediately obvious why |
|
I'm going to deem this resolved with the addition of Feel free to comment or reopen if you disagree. |
Issue by pornel
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::max
can't comparef64
numbers. I know that strictly speaking IEEE floats don't have total order this function expects, but still it's surprising (andpartial_max
is awkward to use).And there's
std::num::Float::max
which works withf64
just fine (the docs don't even say howNaN
is handled).It bugs me that the two versions of
max
are not consistent in their strictness, and that the first-and-most-obviousmax
function in the stdlib "doesn't work" with a basic type in the language.My suggestion:
max
version that only allowsOrd
to something else, liketotal_max
orstrict_max
.std::cmp::max
for floating point numbers, so thata.max(b)
is consistent withmax(a,b)
.The text was updated successfully, but these errors were encountered: