bigdecimal-ethers-ext

Crates.iobigdecimal-ethers-ext
lib.rsbigdecimal-ethers-ext
version0.2.1
sourcesrc
created_at2023-07-18 02:12:02.732635
updated_at2023-09-14 02:50:47.007473
descriptionLibrary allowing conversion between BigDecimal and ethers
homepagehttps://github.com/rellfy/bigdecimal-ethers-ext
repositoryhttps://github.com/rellfy/bigdecimal-ethers-ext
max_upload_size
id919009
size101,885
Lorenzo Fontoura (rellfy)

documentation

README

bigdecimal-ethers-ext

BigDecimal interoperability with ethers-rs types.

Example

let big_decimal = BigDecimal::from_f64(10.5).unwrap();
// Convert to an u256 with 18 decimals.
let u256 = big_decimal.to_ethers_u256(18).unwrap();
println!("{u256}");
// 10500000000000000000
// Convert from an u256 with 18 decimals to a BigDecimal.
let to_big_decimal = BigDecimal::from_ethers_u256(&u256, 18).unwrap();
println!("{to_big_decimal}");
// 10.500000000000000000
Commit count: 18

cargo fmt