-
Notifications
You must be signed in to change notification settings - Fork 4
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
SplayTreeSet treats -0 and 0 as different numbers #675
Comments
This is expected based on the documented semantics. SplayTreeSet says:
So it's based on
and even a pair of examples: // The following comparisons yield different results than the
// corresponding comparison operators.
print((-0.0).compareTo(0.0)); // => -1
// …
// -0.0, and NaN comparison operators have rules imposed by the IEEE
// standard.
print(-0.0 == 0.0); // => true That still leaves the question of whether it should behave that way. It's definitely a bit messy, but I'm not sure there's a better alternative. There are good reasons for each of the different pieces of this, even though the combined result feels a bit out of alignment. In particular, the difference between
The two implementations' behavior is perfectly coherent as long as |
Thanks for such a great explanation! |
outputs
{0}
Meanwhile:
outputs
{-0.0, 0}
I don't know if it's expected, but
gives me
true
, so I expect Set (and any of its implementations) to treat it as the same numberThe text was updated successfully, but these errors were encountered: