#mathematics #numerics #bignum

num-bigint

Big integer implementation for Rust

20 releases

✓ Uses Rust 2018 edition

0.3.0 Jun 12, 2020
0.2.6 Jan 27, 2020
0.2.3 Sep 4, 2019
0.2.2 Dec 14, 2018
0.1.33 Jul 12, 2016

#91 in Math

Download history 65860/week @ 2020-03-16 72720/week @ 2020-03-23 68986/week @ 2020-03-30 65516/week @ 2020-04-06 66586/week @ 2020-04-13 73175/week @ 2020-04-20 72418/week @ 2020-04-27 67497/week @ 2020-05-04 83213/week @ 2020-05-11 83921/week @ 2020-05-18 85548/week @ 2020-05-25 98514/week @ 2020-06-01 98701/week @ 2020-06-08 89577/week @ 2020-06-15 97217/week @ 2020-06-22 86606/week @ 2020-06-29

329,775 downloads per month
Used in 676 crates (212 directly)

MIT/Apache

245KB
6.5K SLoC

num-bigint

crate documentation minimum rustc 1.31 build status

Big integer types for Rust, BigInt and BigUint.

Usage

Add this to your Cargo.toml:

[dependencies]
num-bigint = "0.3"

Features

The std crate feature is enabled by default, and is mandatory before Rust 1.36 and the stabilized alloc crate. If you depend on num-bigint with default-features = false, you must manually enable the std feature yourself if your compiler is not new enough.

Random Generation

num-bigint supports the generation of random big integers when the rand feature is enabled. To enable it include rand as

rand = "0.7"
num-bigint = { version = "0.3", features = ["rand"] }

Note that you must use the version of rand that num-bigint is compatible with: 0.7.

Releases

Release notes are available in RELEASES.md.

Compatibility

The num-bigint crate is tested for rustc 1.31 and greater.

Alternatives

While num-bigint strives for good performance in pure Rust code, other crates may offer better performance with different trade-offs. The following table offers a brief comparison to a few alternatives.

Crate License Min rustc Implementation
num-bigint MIT/Apache-2.0 1.31 pure rust
ramp Apache-2.0 nightly rust and inline assembly
rug LGPL-3.0+ 1.37 bundles GMP via gmp-mpfr-sys
rust-gmp MIT stable? links to GMP
apint MIT/Apache-2.0 1.26 pure rust (unfinished)

Dependencies

~130–380KB