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

Ordering for Dec type is buggy #1762

Closed
brentstone opened this issue Jul 25, 2023 · 3 comments · Fixed by #1763
Closed

Ordering for Dec type is buggy #1762

brentstone opened this issue Jul 25, 2023 · 3 comments · Fixed by #1763

Comments

@brentstone
Copy link
Collaborator

The ordering for Dec types does not work properly for large numbers it seems. An example encountered in the ledger can be summarized with the following lines:

let smaller = Dec::from_str("6483947304.195066085701").unwrap();
let larger = Dec::from_str("32418116583.390243854642").unwrap();
assert!(smaller < larger);

The above assertion fails.

@brentstone
Copy link
Collaborator Author

@batconjurer

@batconjurer
Copy link
Member

So the Ord implementation for I256 accidentally inherited from the Ord implementation on [u64; 4], not Uint([u64; 4]) which is an issue since the Uint type is little endian.

@batconjurer
Copy link
Member

But the ordering would be correct if only the lowest u64 word was used.

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 a pull request may close this issue.

2 participants