| Crates.io | near-bigdecimal |
| lib.rs | near-bigdecimal |
| version | 0.1.1 |
| created_at | 2022-11-24 03:06:42.067855+00 |
| updated_at | 2022-12-09 12:19:43.292857+00 |
| description | Big decimal for NEAR smart contracts |
| homepage | |
| repository | https://github.com/dongcool/near-bigdecimal |
| max_upload_size | |
| id | 721976 |
| size | 12,979 |
Big decimal for NEAR smart contracts
let a = BigDecimal::from(3_u128);
let b = BigDecimal::from(10_u128);
let c = BigDecimal::from(49_u128);
assert_eq!((a + b).round_u128(), 13);
assert_eq!((a * b).round_u128(), 30);
assert_eq!((b / a).round_u128(), 3);
assert_eq!((b.pow(2)).round_u128(), 100);
assert_eq!((c.sqrt()).round_u128(), 7);