Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

199: Optimizations for multiplication r=cuviper a=cuviper

Relevant benchmarks:

```
 factorial_100          5,137                 2,663                      -2,474  -48.16%   x 1.93
 factorial_div_biguint  791,253               773,134                   -18,119   -2.29%   x 1.02
 factorial_div_u32      766,341               748,398                   -17,943   -2.34%   x 1.02
 factorial_mul_biguint  113,269               58,480                    -54,789  -48.37%   x 1.94
 factorial_mul_u32      35,062                37,848                      2,786    7.95%   x 0.93
 multiply_0             39                    40                              1    2.56%   x 0.98
 multiply_1             3,693                 3,708                          15    0.41%   x 1.00
 multiply_2             309,911               215,371                   -94,540  -30.51%   x 1.44
 multiply_3             662,091               494,419                  -167,672  -25.32%   x 1.34
 pow_bench              2,550,050             2,144,069                -405,981  -15.92%   x 1.19
 pow_bench_1e1000       1,332                 1,071                        -261  -19.59%   x 1.24
 pow_bench_1e10000      62,234                36,109                    -26,125  -41.98%   x 1.72
 pow_bench_1e100000     2,530,757             1,134,613              -1,396,144  -55.17%   x 2.23
 pow_bench_bigexp       2,630,660             2,155,688                -474,972  -18.06%   x 1.22
```

Co-authored-by: Josh Stone <cuviper@gmail.com>
125fbbd

Git stats

Files

Permalink
Failed to load latest commit information.

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.4"

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.8"
num-bigint = { version = "0.4", features = ["rand"] }

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

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)

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.