#bigint #bignum #mathematics

no-std ibig

A big integer library with good performance

11 unstable releases (3 breaking)

0.3.2 May 3, 2021
0.3.1 Apr 3, 2021
0.3.0 Mar 29, 2021
0.2.2 Mar 28, 2021
0.0.0 Nov 20, 2020

#51 in Math

Download history 656/week @ 2021-07-03 791/week @ 2021-07-10 701/week @ 2021-07-17 775/week @ 2021-07-24 311/week @ 2021-07-31 213/week @ 2021-08-07 538/week @ 2021-08-14 306/week @ 2021-08-21 608/week @ 2021-08-28 719/week @ 2021-09-04 736/week @ 2021-09-11 665/week @ 2021-09-18 616/week @ 2021-09-25 1053/week @ 2021-10-02 651/week @ 2021-10-09 640/week @ 2021-10-16

1,565 downloads per month
Used in 3 crates

MIT/Apache

305KB
7.5K SLoC

ibig

crate docs rustc 1.47+ tests

A big integer library with good performance.

The library implements efficient large integer arithmetic in pure Rust.

The two integer types are UBig (for unsigned integers) and IBig (for signed integers).

Modular arithmetic is supported by the module modular.

Examples

use ibig::{ibig, modular::ModuloRing, ubig, UBig};

let a = ubig!(12345678);
let b = ubig!(0x10ff);
let c = ibig!(-azz base 36);
let d: UBig = "15033211231241234523452345345787".parse()?;

assert_eq!(c.to_string(), "-14255");
assert_eq!(
    (a * b.pow(10)).in_radix(16).to_string(),
    "1589bda8effbfc495d8d73c83d8b27f94954e"
);
assert_eq!(
    format!("hello {:#x}", d % ubig!(0xabcd1234134132451345)),
    "hello 0x1a7e7c487267d2658a93"
);

let ring = ModuloRing::new(&ubig!(10000));
let x = ring.from(12345);
let y = ring.from(55443);
assert_eq!(format!("{}", x - y), "6902 (mod 10000)");

Benchmarks

Benchmarks contains a quick benchmark of Rust big integer libraries.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~510KB