15 releases

0.3.6 Sep 17, 2022
0.3.5 Mar 12, 2022
0.3.4 Nov 3, 2021
0.3.2 May 3, 2021
0.0.0 Nov 20, 2020

#168 in Math

Download history 1958/week @ 2024-08-05 2034/week @ 2024-08-12 1861/week @ 2024-08-19 2014/week @ 2024-08-26 2292/week @ 2024-09-02 2159/week @ 2024-09-09 1783/week @ 2024-09-16 2035/week @ 2024-09-23 1955/week @ 2024-09-30 2582/week @ 2024-10-07 3624/week @ 2024-10-14 3559/week @ 2024-10-21 4472/week @ 2024-10-28 3266/week @ 2024-11-04 3421/week @ 2024-11-11 3040/week @ 2024-11-18

14,342 downloads per month
Used in 17 crates (14 directly)

MIT/Apache

380KB
10K SLoC

ibig

crate docs rustc 1.49+ 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()?;
let e = 2 * &b + 1;
let f = a * b.pow(10);

assert_eq!(e, ubig!(0x21ff));
assert_eq!(c.to_string(), "-14255");
assert_eq!(
    f.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)");

Optional dependencies

  • std (default): for std::error::Error.
  • num-traits (default): integral traits.
  • rand (default): random number generation.
  • serde: serialization and deserialization.

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

~375–670KB
~11K SLoC