num-bigint
Big integer implementation for Rust
0.5.1
543M downloads/mo
#185 most downloaded on crates.io
rust-num/num-bigint
What this package is like to depend on
Last release 1 months ago
05 Jul 2026
Release timing varies
gaps range from 2 weeks to 1.8 years
Most releases are documented
notes for 23 of 33 stable releases
2 versions withdrawn
withdrawn after publishing
10 years old
35 releases · first in 2016
4 releases in the last 12 months
see the full history below
Release timeline
35 releases · Apr 2016 to Jul 2026Releases
latest 35-
0.5.105 Jul 2026 -
0.5.002 Jul 2026 withdrawnRelease notes
Open source →- Upgrade to
randv0.10 and/or v0.9, and splitrand_core.- The former
randfeature is now split into multiple features,rand_0_9,rand_core_0_9,rand_0_10, andrand_core_0_10, depending on the version and feature set you need. - The
RandBigIntextension trait is now split intoBigRng09andBigRng010for each version. - The
gen_*methods are deprecated in favor of newrandom_*methods. - This is also a value-breaking release, as
randdefines it.
- The former
Contributors: @bionicles, @cuviper, @divergentdave
- Upgrade to
-
0.4.805 Jul 2026 -
0.4.702 Jul 2026 withdrawnRelease notes
Open source →- Inline single-digit values. This reduces heap allocations, and
also enables
const ONE,const NEG_ONE, andconst fn new_const. - Use divide and conquer in
to_radix_digits, also implementing the Burnikel-Ziegler algorithm to speed up large divisions in general. - Implement
LowerBoundedforBigUint.
Contributors: @cp289, @cuviper, @hkalbasi, @mikem8891, @pRizz, @tyilo, @xtqqczze
- Inline single-digit values. This reduces heap allocations, and
also enables
-
0.4.627 Jun 2024 -
0.4.506 May 2024Release notes
Open source →- Upgrade to 2021 edition, MSRV 1.60
- Add
const ZEROand implementnum_traits::ConstZero - Add
modinvmethods for the modular inverse - Optimize multiplication with imbalanced operands
- Optimize scalar division on x86 and x86-64
Contributors: @cuviper, @joelonsql, @waywardmonkeys
-
0.4.422 Aug 2023Release notes
Open source →- Implemented
From<bool>forBigIntandBigUint. - Implemented
num_traits::EuclidandCheckedEuclidforBigIntandBigUint. - Implemented ties-to-even for
BigIntandBigUint::to_f32andto_f64. - Implemented
num_traits::FromBytesandToBytesforBigIntandBigUint. - Limited pre-allocation from serde size hints against potential OOM.
- Miscellaneous other code cleanups and maintenance tasks.
Contributors: @AaronKutch, @archseer, @cuviper, @dramforever, @icecream17, @icedrocket, @janmarthedal, @jaybosamiya, @OliveIsAWord, @PatrickNorton, @smoelius, @waywardmonkeys
- Implemented
-
0.4.303 Nov 2021 -
0.4.203 Sep 2021 -
0.4.128 Aug 2021Release notes
Open source →- Fixed scalar divide-by-zero panics.
- Implemented
DoubleEndedIteratorforU32DigitsandU64Digits. - Optimized multiplication to avoid unnecessary allocations.
- Optimized string formatting for very large values.
Contributors: @cuviper, @PatrickNorton
-
0.4.005 Mar 2021Release notes
Open source →Breaking Changes
- Updated public dependences on arbitrary, quickcheck, and rand:
arbitrarysupport has been updated to 1.0, requiring Rust 1.40.quickchecksupport has been updated to 1.0, requiring Rust 1.46.randsupport has been updated to 0.8, requiring Rust 1.36.
Debugnow shows plain numeric values forBigIntandBigUint, rather than the raw list of internal digits.
Contributors: @cuviper, @Gelbpunkt
- Updated public dependences on arbitrary, quickcheck, and rand:
-
0.3.303 Sep 2021Release notes
Open source →- [Use explicit
Integer::div_ceilto avoid the new unstable method.][219]
Contributors: @catenacyber, @cuviper
- [Use explicit
-
0.3.205 Mar 2021Release notes
Open source →- The new
BigUintmethodscount_onesandtrailing_onesreturn the number of1bits in the entire value or just its least-significant tail, respectively. - The new
BigIntandBigUintmethodsbitandset_bitwill read and write individual bits of the value. For negativeBigInt, bits are determined as if they were in the two's complement representation. - The
from_radix_leandfrom_radix_bemethods now accept empty buffers to represent zero. BigIntandBigUintcan now iterate digits asu32oru64, regardless of the actual internal digit size.
Contributors: @BartMassey, @cuviper, @janmarthedal, @sebastianv89, @Speedy37
- The new
-
0.3.103 Nov 2020Release notes
Open source →- Addition and subtraction now uses intrinsics for performance on
x86andx86_64when built with Rust 1.33 or later. - Conversions
to_f32andto_f64now return infinity for very large numbers, rather thanNone. This does preserve the sign too, so a large negativeBigIntwill convert to negative infinity. - The optional
arbitraryfeature implementsarbitrary::Arbitrary, distinct fromquickcheck::Arbitrary. - The division algorithm has been optimized to reduce the number of temporary allocations and improve the internal guesses at each step.
BigIntandBigUintwill opportunistically shrink capacity if the internal vector is much larger than needed.
Contributors: @cuviper, @e00E, @ejmahler, @notoria, @tczajka
- Addition and subtraction now uses intrinsics for performance on
-
0.3.012 Jun 2020Release notes
Open source →Enhancements
- The internal
BigDigitmay now be eitheru32oru64, although that implementation detail is not exposed in the API. For now, this is chosen to match the target pointer size, but may change in the future. - No-
stdis now supported with thealloccrate on Rust 1.36. Powis now implemented for bigint values, not just references.TryFromis now implemented on Rust 1.34 and later, converting signed integers to unsigned, and narrowing big integers to primitives.ShlandShrare now implemented for a variety of shift types.- A new
trailing_zeros()returns the number of consecutive zeros from the least significant bit. - The new
BigInt::magnitudeandinto_partsmethods give access to itsBigUintpart as the magnitude.
Breaking Changes
num-bigintnow requires Rust 1.31 or greater.- The "i128" opt-in feature was removed, now always available.
- Updated public dependences:
randsupport has been updated to 0.7, requiring Rust 1.32.quickchecksupport has been updated to 0.9, requiring Rust 1.34.
- Removed
impl Neg for BigUint, which only ever panicked. - Bit counts are now
u64instead ofusize.
Contributors: @cuviper, @dignifiedquire, @hansihe, @kpcyrd, @milesand, @tech6hutch
- The internal
-
0.2.627 Jan 2020 -
0.2.510 Jan 2020 -
0.2.401 Jan 2020Release notes
Open source →- The new
BigUint::to_u32_digitsmethod returns the number as a little-endian vector of base-2<sup>32</sup> digits. The same method onBigIntalso returns the sign. BigUint::modpownow applies a modulus even for exponent 1, which also affectsBigInt::modpow.BigInt::modpownow returns the correct sign for negative bases with even exponents.
Contributors: @alex-ozdemir, @cuviper, @dingelish, @Speedy37, @youknowone
- The new
-
0.2.304 Sep 2019Release notes
Open source →Powis now implemented forBigUintexponents.- The optional
quickcheckfeature enables implementations ofArbitrary. - See the full comparison for performance enhancements and more!
Contributors: @cuviper, @lcnr, @maxbla, @mikelodder7, @mikong, @TheLetterTheta, @tspiteri, @XAMPPRocky, @youknowone
-
0.2.214 Dec 2018Release notes
Open source →- The
Rootsimplementations now use better initial guesses. - Fixed
to_signed_bytes_*for some positive numbers, where the most-significant byte is0x80and the rest are0.
Contributors: @cuviper, @leodasvacas
- The
-
0.2.103 Nov 2018Release notes
Open source →RandBigIntnow usesRng::fill_bytesto improve performance, instead of repeatedgen::<u32>calls. The also affects the implementations of the otherrandtraits. This may potentially change the values produced by some seeded RNGs on previous versions, but the values were tested to be stable withChaChaRng,IsaacRng, andXorShiftRng.BigIntandBigUintnow implementnum_integer::Roots.BigIntandBigUintnow implementnum_traits::Pow.BigIntandBigUintnow implement operators with 128-bit integers.
Contributors: @cuviper, @dignifiedquire, @mancabizjak, @Robbepop, @TheIronBorn, @thomwiggers
-
0.2.025 May 2018Release notes
Open source →Enhancements
BigIntandBigUintnow implementProductandSumfor iterators of any item that we canMulandAdd, respectively. For example, a factorial can now be simply:let f: BigUint = (1u32..1000).product();BigIntnow supports two's-complement logic operations, namelyBitAnd,BitOr,BitXor, andNot. These act conceptually as if each number had an infinite prefix of0or1bits for positive or negative.BigIntnow supports assignment operators likeAddAssign.BigIntandBigUintnow support conversions withi128andu128, if sufficient compiler support is detected.BigIntandBigUintnow implement rand'sSampleUniformtrait, and a customRandomBitsdistribution samples by bit size.- The release also includes other miscellaneous improvements to performance.
Breaking Changes
num-bigintnow requires rustc 1.15 or greater.- The crate now has a
stdfeature, and won't build without it. This is in preparation for someday supporting#![no_std]withalloc. - The
serdedependency has been updated to 1.0, still disabled by default. Therustc-serializecrate is no longer supported bynum-bigint. - The
randdependency has been updated to 0.5, now disabled by default. This requires rustc 1.22 or greater forrand's own requirement. Shr for BigIntnow rounds down rather than toward zero, matching the behavior of the primitive integers for negative values.ParseBigIntErroris now an opaque type.- The
big_digitmodule is no longer public, nor are theBigDigitandDoubleBigDigittypes andZERO_BIG_DIGITconstant that were re-exported in the crate root. Public APIs which deal in digits, likeBigUint::from_slice, will now always be base-u32.
Contributors: @clarcharr, @cuviper, @dodomorandi, @tiehuis, @tspiteri
-
0.1.4525 Jan 2025Nothing published for this version
-
0.1.4414 May 2018Release notes
Open source →- Division with single-digit divisors is now much faster.
- The README now compares
ramp,rug,rust-gmp, andapint.
Contributors: @cuviper, @Robbepop
-
0.1.4309 Feb 2018Release notes
Open source →- The new
BigInt::modpowperforms signed modular exponentiation, using the existingBigUint::modpowand rounding negatives similar tomod_floor.
Contributors: @cuviper
- The new
-
0.1.4208 Feb 2018Release notes
Open source →- num-bigint now has its own source repository at rust-num/num-bigint.
lcmnow avoids creating a large intermediate product.gcdnow uses Stein's algorithm with faster shifts instead of division.randsupport is now extended to 0.4 (while still allowing 0.3).
Contributors: @cuviper, @Emerentius, @ignatenkobrain, @mhogrefe
-
0.1.4101 Dec 2017Nothing published for this version
-
0.1.4015 Jul 2017Nothing published for this version
-
0.1.3909 Jun 2017Nothing published for this version
-
0.1.3809 Jun 2017Nothing published for this version
-
0.1.3708 Mar 2017Nothing published for this version
-
0.1.3626 Feb 2017Nothing published for this version
-
0.1.3518 Aug 2016Nothing published for this version
-
0.1.3312 Jul 2016Nothing published for this version
-
0.1.3214 Apr 2016Nothing published for this version