-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
add cmp() to f32 and f64, with tests #12193
Conversation
Sometimes, it becomes necessary to find out if one of your floats is bigger or smaller than another one of your floats. In my case, I had a list of floats I had calculated, and I wanted to sort them biggest to smallest. Using `sort_by()` requires cmp, so I initially wrote my own fcmp, and then realized that was silly and it should just be built in.
It's not a correct implementation of
The first two requirements are not true for floating point types using this implementation. It's separate from What should |
So the official stance of Rust is that it's not possible to sort floats? Is this pull so unfixable that it really deserved to be closed without comment beyond "it's wrong sometimes"? |
@indirect I believe that, by definition, IEEE floating-point values cannot possibly implement |
@indirect: The |
I gathered "not the right solution". That's a very concise restatement leading to my previous question, which is still unanswered. What is the right way? I'm somewhat incredulous because, as far as I can tell, your answer seems to be "never want to sort floats". On Tue, Feb 11, 2014 at 2:54 PM, Daniel Micay notifications@github.com
|
I think we should have |
fix: Fix panics on GATs involving const generics This workaround avoids constant crashing of rust analyzer when using GATs with const generics, even when the const generics are only on the `impl` block. The workaround treats GATs as non-existing if either itself or the parent has const generics and removes relevant panicking code-paths. Fixes rust-lang#11989, fixes rust-lang#12193
Sometimes, it becomes necessary to find out if one of your floats is
bigger or smaller than another one of your floats. In my case, I had a
list of floats I had calculated, and I wanted to sort them biggest to
smallest. Using
sort_by()
requires cmp, so I initially wrote my ownfcmp, and then realized that was silly and it should just be built in.