Skip to content

Commit

Permalink
Merge branch 'bat/fix/dec-ord' (#1763)
Browse files Browse the repository at this point in the history
* origin/bat/fix/dec-ord:
  added changelog
  [fix]: Fixed ordering for Dec and I256 types
  • Loading branch information
Fraccaman committed Jul 26, 2023
2 parents 8139da2 + d5c2f92 commit a1fd70f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
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);
}
}
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

0 comments on commit a1fd70f

Please sign in to comment.