Module num_bigint
Arbitrary precision integers.
- Crate
::num_bigint. - docs.rs
- crates.io
- GitHub
num-bigint provides BigInt and BigUint types
for arbitrary precision integer arithmetic.
These types can represent integers of any size,
limited only by available memory.
BigInt is a signed arbitrary precision integer,
while BigUint is an unsigned arbitrary precision integer.
Both support the standard arithmetic operations
and can be converted to and from standard integer types
and strings.
The types implement many of the same traits as the built-in integer types, making them easy to use as drop-in replacements when you need larger integers.
Examples
Basic arithmetic with big integers:
use ;
// Create big integers from standard types
let a = from;
let b = "123456789012345678901234567890"..unwrap;
// Arithmetic operations work as expected
let sum = &a + &b;
let product = &a * &b;
// Convert back to strings for display
println!;
println!;
Computing large factorials:
use BigUint;
// Compute 100! (which is very large)
let result = factorial;
println!;
Structs
- ParseBigIntError
- TryFromBigIntError The error type returned when a checked conversion regarding big integer fails.