Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/1763-fix-dec-ord.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixes the ordering for I256 type.
([\#1763](https://github.com/anoma/namada/pull/1763))
7 changes: 7 additions & 0 deletions core/src/types/dec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,4 +613,11 @@ mod test_dec {
.unwrap()
);
}

#[test]
fn test_ordering() {
let smaller = Dec::from_str("6483947304.195066085701").unwrap();
let larger = Dec::from_str("32418116583.390243854642").unwrap();
assert!(smaller < larger);
}
Comment on lines +617 to +622
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
Collaborator 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.

}
4 changes: 2 additions & 2 deletions core/src/types/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ impl PartialOrd for I256 {
(true, true) => {
let this = self.abs();
let that = other.abs();
this.0.partial_cmp(&that.0)
this.partial_cmp(&that)
}
(false, false) => {
let this = self.abs();
let that = other.abs();
that.0.partial_cmp(&this.0)
that.partial_cmp(&this)
}
}
}
Expand Down