UBig::to_digits/UBig::from_digits: convert to and from a sequence of base-Bdigits (base2..=Word::MAX, digits stored asWord, most-significant first). Complements [UBig::in_radix] which is limited to base 2..=36.
- Fixed a broken intra-doc link in
MontgomeryRepr's docs (a[...](self)link that resolved to a private item is removed), surfaced bycargo doc -D warnings. UBig::nth_root/IBig::nth_root(andcbrt) of0returned1instead of0: thebits <= nshortcut fired for the zero input (bit length 0). Found by the newfuzz/rug::Integeroracle.
- (breaking)
IBig's serde non-human-readable format switched from the custom byte-length-parity encoding to standard two's complement little-endian bytes (matching [IBig::to_le_bytes]), for interop robustness. Previously serialized data is not compatible. - (breaking)
UBig::in_radixandIBig::in_radixnow takeradix: u8(wasu32); the internalDigittype alias is nowu8.from_str_with_radix_prefix/from_str_with_radix_defaultnow expose the detected/default radix asu8(wasu32).from_str_radixkeeps itsu32argument forstdparity.
- NTT-based multiplication using Proth primes (
K·2^N + 1) combined via Garner CRT, with 64-bit transform coefficients. Enabled on both 64-bit and 32-bitWordtargets; activates above ~4 000 words (~256 kbits). Auto-selectsK_eff = 2primes when headroom allows. - Asymmetric NTT: when one operand is much larger than the other, the shorter operand is forward-transformed once and reused across chunks.
montymodule: Montgomery modular arithmetic for odd moduli.MontgomeryRepr(precomputed constants) andMontgomery(values in Montgomery form) support multiplication, squaring, addition, subtraction, negation, doubling, exponentiation, and inversion.- Specialized squaring paths for Karatsuba, Toom-Cook-3, and NTT (recursive squarings instead of multiplications / a single forward transform), with separately tunable thresholds.
UBig::from_u64andIBig::from_i64const constructors (on 32-bit and 64-bit targets).- Optional
rand_v09(rand 0.9, MSRV 1.63) andrand_v010(rand 0.10, MSRV 1.85) features mirroringrand_v08. The defaultrandfeature still maps torand_v08. - The random-integer distributions (
UniformBits,UniformBelow,UniformUBig,UniformIBig) and their sampling now live once in the version-agnosticdashu_int::randmodule, which exposes aBitRngtrait andbridge_v08/bridge_v09/bridge_v010constructors. The per-version modules are now private trait bindings.
- Basecase (schoolbook) multiplication and squaring now use a double-word addmul inner kernel, roughly halving accumulator memory traffic; on x86-64 with
stdit dispatches to a BMI2 build lowered tomulx. - Addition and subtraction carry/borrow propagation now uses
Wordinstead ofbool, eliminating conversions in the inner loops. - Lowered the Karatsuba→Toom-3 multiplication threshold from 192 to 96 words (~6 000 bits instead of ~12 000 bits).
UBig::nth_rootfor large compositendecomposes into a chain of smaller roots via small-prime factor reduction, avoiding the prohibitively expensive Newton term.- Integer logarithm for very large values uses power-sequence decomposition instead of iterative single-step multiplication.
- Non-power-of-2 radix formatting preallocates its conversion buffers instead of growing them incrementally, and optimizes single-digit writes.
- Multiplication, squaring, and division thresholds can be overridden at runtime via
DASHU_THRESHOLD_*environment variables (requirestuningfeature):DASHU_THRESHOLD_{SIMPLE,KARATSUBA,NTT}_MUL,DASHU_THRESHOLD_{SIMPLE,KARATSUBA,NTT}_SQR, andDASHU_THRESHOLD_SIMPLE_DIV.
- Fix modular exponentiation and
Reduced::sqrunder-allocating scratch for squaring, which could exhaust the scratch allocator mid-recursion for moduli in the Karatsuba band. - Fix a panic in the extended GCD when one operand divides the other.
- Fix
IBig::{to_le_bytes, to_be_bytes}for negative powers of two. - Fix
IBig >> n(shift byn >= bit length) onDoubleWord-magnitude values. - Fix the 32-bit
Wordbuild: the NTT pack code, test literals, and unused-import warnings on targets where the NTT arm is compiled out.
- Add
UBig::ones. - Add
IBig::as_ubig. - Add
UBig::from_chunksandUBig::to_chunks. - Implement
TryFrom<UBig>andTryFrom<IBig>forf32/f64. - Implement
IBig::{from_le_bytes, from_be_bytes}andIBig::{to_le_bytes, to_be_bytes}. - The alterative
Debugoutput ofUBigandIBigwill include(digits: x, bits: y)instead of(x digits, y bits). - Implement bit operations (
BitAnd,BitOr,BitXor) betweenUBigandIBig, and betweenIBigand unsigned primitive integers. - Fix a bug in
UBig::split_bitsandUBig::clear_high_bits. - Reduce unsafe code (#52 thanks to @eduardosm).
- Fix
words_to_chunkspanic on 32-bitWordtargets. (#63). - FIx bugs in
to_f64andsqrt_rem_large(#64). - Bump MSRV from 1.61 to 1.68.
- Implement
AbsEqandAbsOrdforUBigandIBig. - Add
UBig::from_static_wordsandIBig::from_static_words(both Rust 1.64+) to support thestatic_ubig!andstatic_ibig!macros. - Add
is_multiple_ofandis_multiple_of_const(Rust 1.64+) forUBig/IBig - Constify
trailing_zerosandtrailing_onesofUBig/IBig(Rust 1.64+). IBig::trailing_onesbug fixed.
- Add a
ConstDivisortype that supports faster division when you have an invariant number as the divisor. - Add
as_ibigmethod toUBig. - Implement
num_order::NumOrdtrait betweenUBigandIBig - Implement
num_modular::Reducertrait forConstDivisor
- The serialization format with
serdeforUBigandIBighas been changed. Now both types will be serialize as a sequence of little-endian bytes. - Now feature
num-traitsandrandare not enabled by default, featurenum-orderis enabled instead. - The
IntoModuletrait is refactored into theIntoRingtrait, which has an additional type parameter for the ring. This is used for potential Montgomery implementation in future. - The
IntoRingtrait is no longer implemented for reference types&UBigand&IBigto make the copying explicit. - The
Modulotype is renamed toReducedto prevent confusion. From<&UBig>implementation forIBigandTryFrom<&IBig>forUBigare removed to prevent implicit cloning.BitAndforUBigand other primitive integer types now will always return the result with primitive integer type.
- The comparison traits
PartialOrdandPartialEqare no longer implemented betweenUBigandIBig. Usenum_order::NumOrdinstead.
- Add struct
crate::rand::UniformBitsfor generating random integers with given bit lenght limit. - Add
count_ones()andcount_zeros()forUBig - Add
cubic()forUBigandIBig - Add
rand_v08andnum-traits_v02feature flags to prevent breaking changes due to dependency updates in future
- Implement
Gcd::gcdandExtendedGcd::gcd_extbetweenUBigandIBig - Implement
DivRem::div_rembetweenUBigandIBig - Implement
dashu_base::BitTestforIBig - Implement
DivandDivAssignforModulo - Add
trailing_onesforUBigandIBig - Implement
TryFrom<f32>andTryFrom<f64>forUBigandIBig - Implement
num_order::{NumOrd<f32>, NumOrd<f64>forUBigandIBig
sqrt_remis only exposed through thedashu_base::RootRemtrait now.abs_cmpis only exposed throught thedashu_base::AbsCmptrait now.abs_eqis only exposed throught thedashu_base::AbsEqtrait now.bit_lenandbitare only exposed throught thedashu_base::BitTesttrait now.Modulo::invnow takes the reference of aModulo.to_le_bytesandto_be_bytesnow return a boxed arrayBox<[u8]>instead of aVec<u8>IBig::square()now returnsUBiginstead ofIBig
error::{OutOfBoundsError, ParseError}are removed, related error types are added todashu-basePartialOrdandPartialEqis not implemented for primitive integers any more. Please usenum_order::NumOrdfor comparison. (Seenum-bigint#150)num-integerfeature is not enabled by default now.
- Add
sqrt,sqrt_rem,nth_rootforUBigandIBig - Implement
core::iter::{Sum, Product}forUBigandIBig - Implement
num_traits::{Euclid, ToPrimitive, FromPrimitive}forUBigandIBig - Implement
num_integer::{Integer, Roots}forUBigandIBig - Implement
num_order::{NumHash, NumOrd}forUBigandIBig - Implement
zeroize::ZeroizeforUBig,IBigand internal types serdese/derialization now supports theis_human_readable()flag
- Expose the
Signenum and related operations withUBigandIBig - Expose
DoubleWordfor easier operation withWord - Add a public API
as_wordsandas_sign_wordsto access internal representation ofUBigandIBigrespectively. - Add const constructors
from_word,from_dwordand a direct constructorfrom_wordsforUBig. - Add a const constructor
from_parts_constand a director constructorfrom_partsforIBig - Add
split_bitsandclear_high_bitsforUBig. - Add
removeforUBig - Add
abs_cmp,abs_eqforIBig. - Implement
MulbetweenSignandUBig/IBig. - Implement
DivRemAssignforUBigandIBig, andDivRemAssignis re-exported in theopsmodule. - Implement integer logarithm
ilogand approximated bounds of base 2 logarithmlog2_bounds.
- Remove
ubig!andibig!macros from the crate, more powerful versions of them will be included in a separatedashu-macrocrate.
- Function
zero(),one(),neg_one()are changed to associated constantsZERO,ONE,NEG_ONE. - Function
gcd()andextended_gcd()ofUBigandIBigare changed to be associated functions ofGcdandExtendedGCD. - Parsing a string with unsupported radix will now return an Err instead of
panic!. from_str_with_radix_prefixnow also return the radix.- Due to the requirement of
dashu-float, the MSRV is now 1.61. Rust versions from 1.57 to 1.60 are still working fordashu-intin this version, but it won't be ensured in future releases.
- Parsing integers from string support underscore separater.
- Improve speed for power function
pow()
- Implemented modular inverse for the
Modulotype. - Implemented
gcdandextended_gcdforUBigandIBig.
The code for big integer is ported from ibig @ 0.3.5 with modifications stated in the NOTICE, the current MSRV for dashu-int is 1.57.