#decimal #arbitrary-precision #numeric

no-std bignumber

A Rust library for arbitrary-precision decimal and non-decimal arithmetic

17 releases

0.1.1 Dec 7, 2023
0.1.0 Dec 7, 2023
0.0.16 Nov 6, 2022

#316 in Math

Download history 1/week @ 2024-01-19 12/week @ 2024-01-26 9/week @ 2024-02-02 1/week @ 2024-02-09 13/week @ 2024-02-16 55/week @ 2024-02-23 6/week @ 2024-03-01 15/week @ 2024-03-08 12/week @ 2024-03-15 17/week @ 2024-03-29 7/week @ 2024-04-05

99 downloads per month

MIT license

16KB
459 lines

bignumber (WIP)

A Rust library for arbitrary-precision decimal and non-decimal arithmetic built on top of dashu-float

Install

cargo add bignumber

cargo add bignumber -F precision-512

Usage

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(())
}

Dependencies

~2MB
~38K SLoC