Skip to content
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

common: cope with i64::MIN in PartialOrd #91

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

daviddrysdale
Copy link
Collaborator

Negating i64::MIN gives a positive value that is > i64::MAX.

(-1, -1) => (-i1).cmp(&(-i2)),
(-1, -1) => match i1.cmp(i2) {
Ordering::Less => Ordering::Greater,
Ordering::Equal => Ordering::Equal,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not equivalent to i2.cmp(i1) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done.

Negating i64::MIN gives a positive value that is > i64::MAX.
@daviddrysdale daviddrysdale merged commit de47f83 into google:main Apr 5, 2024
21 checks passed
@daviddrysdale daviddrysdale deleted the i64-min branch April 5, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants