17个版本
0.1.1 | 2023年12月7日 |
---|---|
0.1.0 | 2023年12月7日 |
0.0.16 | 2022年11月6日 |
358 在 数学
24 每月下载次数
16KB
459 行
bignumber (WIP)
基于dashu-float构建的Rust库,用于任意精度十进制和非十进制算术
安装
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(())
}
依赖
~2MB
~38K SLoC