Skip to content

Commit a31e81f

Browse files
committed
Test to_uint_floor for value < 1
1 parent 3b7b3a4 commit a31e81f

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

packages/std/src/math/decimal.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,8 @@ mod tests {
20622062
assert_eq!(d.to_uint_floor(), Uint128::new(12));
20632063
let d = Decimal::from_str("12.999").unwrap();
20642064
assert_eq!(d.to_uint_floor(), Uint128::new(12));
2065+
let d = Decimal::from_str("0.98451384").unwrap();
2066+
assert_eq!(d.to_uint_floor(), Uint128::new(0));
20652067

20662068
let d = Decimal::from_str("75.0").unwrap();
20672069
assert_eq!(d.to_uint_floor(), Uint128::new(75));

packages/std/src/math/decimal256.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,8 @@ mod tests {
22092209
assert_eq!(d.to_uint_floor(), Uint256::from_u128(12));
22102210
let d = Decimal256::from_str("12.999").unwrap();
22112211
assert_eq!(d.to_uint_floor(), Uint256::from_u128(12));
2212+
let d = Decimal256::from_str("0.98451384").unwrap();
2213+
assert_eq!(d.to_uint_floor(), Uint256::from_u128(0));
22122214

22132215
let d = Decimal256::from_str("75.0").unwrap();
22142216
assert_eq!(d.to_uint_floor(), Uint256::from_u128(75));

0 commit comments

Comments
 (0)