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

[fix]: Fixed ordering for Dec and I256 types #1763

Merged
merged 2 commits into from
Jul 26, 2023
Merged

Conversation

batconjurer
Copy link
Member

Fixes #1762

@batconjurer batconjurer requested a review from brentstone July 25, 2023 22:45
brentstone
brentstone previously approved these changes Jul 26, 2023
Copy link
Collaborator

@brentstone brentstone left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

Fraccaman added a commit that referenced this pull request Jul 26, 2023
* origin/bat/fix/dec-ord:
  added changelog
  [fix]: Fixed ordering for Dec and I256 types
@Fraccaman Fraccaman mentioned this pull request Jul 26, 2023
Copy link
Contributor

@bengtlofgren bengtlofgren left a comment

Choose a reason for hiding this comment

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

Could you just describe what the difference was here? What did the .0 do?

@bengtlofgren adding .0 meant you were comparing the inner uints, and not the signed values. I think this was the source of the issue. here's an example illustrating the issue

Comment on lines +617 to +622
#[test]
fn test_ordering() {
let smaller = Dec::from_str("6483947304.195066085701").unwrap();
let larger = Dec::from_str("32418116583.390243854642").unwrap();
assert!(smaller < larger);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldn't this test have passed before, with the faulty comparisons?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it needs 2 u64 words to be stored.

@Fraccaman Fraccaman merged commit a1fd70f into main Jul 26, 2023
@Fraccaman Fraccaman deleted the bat/fix/dec-ord branch July 26, 2023 19:43
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.

Ordering for Dec type is buggy
5 participants