Crates.io | bignumber |
lib.rs | bignumber |
version | 0.1.1 |
source | src |
created_at | 2022-11-01 14:51:51.574073 |
updated_at | 2023-12-07 20:22:41.016943 |
description | A Rust library for arbitrary-precision decimal and non-decimal arithmetic |
homepage | https://github.com/KABBOUCHI/bignumber-rs |
repository | https://github.com/KABBOUCHI/bignumber-rs |
max_upload_size | |
id | 702847 |
size | 16,723 |
A Rust library for arbitrary-precision decimal and non-decimal arithmetic built on top of dashu-float
cargo add bignumber
cargo add bignumber -F precision-512
use std::ops::Div;
use bignumber::{BigNumber, BigNumberError};
fn main() -> Result<(), BigNumberError> {
let a = BigNumber::of("1.0001")?;
let b = BigNumber::of("4096")?;
let c = a.pow(&b);
let d = BigNumber::from(10).powi(18);
let e = ethereum_types::U256::max_value();
let f = BigNumber::from(e);
println!("{}", a);
println!("{}", b);
println!("{}", c);
println!("{} ETH", BigNumber::of("44700000000000000")?.div(d));
println!("{}", f);
Ok(())
}