- Add
UBig::ones
. - Add
IBig::as_ubig
. - Add
UBig::from_chunks
andUBig::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
Debug
output ofUBig
andIBig
will include(digits: x, bits: y)
instead of(x digits, y bits)
. - Implement bit operations (
BitAnd
,BitOr
,BitXor
) betweenUBig
andIBig
, and betweenIBig
and unsigned primitive integers. - Fix a bug in
UBig::split_bits
andUBig::clear_high_bits
- Implement
AbsEq
andAbsOrd
forUBig
andIBig
. - Add
UBig::from_static_words
andIBig::from_static_words
(both Rust 1.64+) to support thestatic_ubig!
andstatic_ibig!
macros. - Add
is_multiple_of
andis_multiple_of_const
(Rust 1.64+) forUBig
/IBig
- Constify
trailing_zeros
andtrailing_ones
ofUBig
/IBig
(Rust 1.64+). IBig::trailing_ones
bug fixed.
- Add a
ConstDivisor
type that supports faster division when you have an invariant number as the divisor. - Add
as_ibig
method toUBig
. - Implement
num_order::NumOrd
trait betweenUBig
andIBig
- Implement
num_modular::Reducer
trait forConstDivisor
- The serialization format with
serde
forUBig
andIBig
has been changed. Now both types will be serialize as a sequence of little-endian bytes. - Now feature
num-traits
andrand
are not enabled by default, featurenum-order
is enabled instead. - The
IntoModule
trait is refactored into theIntoRing
trait, which has an additional type parameter for the ring. This is used for potential Montgomery implementation in future. - The
IntoRing
trait is no longer implemented for reference types&UBig
and&IBig
to make the copying explicit. - The
Modulo
type is renamed toReduced
to prevent confusion. From<&UBig>
implementation forIBig
andTryFrom<&IBig>
forUBig
are removed to prevent implicit cloning.BitAnd
forUBig
and other primitive integer types now will always return the result with primitive integer type.
- The comparison traits
PartialOrd
andPartialEq
are no longer implemented betweenUBig
andIBig
. Usenum_order::NumOrd
instead.
- Add struct
crate::rand::UniformBits
for generating random integers with given bit lenght limit. - Add
count_ones()
andcount_zeros()
forUBig
- Add
cubic()
forUBig
andIBig
- Add
rand_v08
andnum-traits_v02
feature flags to prevent breaking changes due to dependency updates in future
- Implement
Gcd::gcd
andExtendedGcd::gcd_ext
betweenUBig
andIBig
- Implement
DivRem::div_rem
betweenUBig
andIBig
- Implement
dashu_base::BitTest
forIBig
- Implement
Div
andDivAssign
forModulo
- Add
trailing_ones
forUBig
andIBig
- Implement
TryFrom<f32>
andTryFrom<f64>
forUBig
andIBig
- Implement
num_order::{NumOrd<f32>, NumOrd<f64>
forUBig
andIBig
sqrt_rem
is only exposed through thedashu_base::RootRem
trait now.abs_cmp
is only exposed throught thedashu_base::AbsCmp
trait now.abs_eq
is only exposed throught thedashu_base::AbsEq
trait now.bit_len
andbit
are only exposed throught thedashu_base::BitTest
trait now.Modulo::inv
now takes the reference of aModulo
.to_le_bytes
andto_be_bytes
now return a boxed arrayBox<[u8]>
instead of aVec<u8>
IBig::square()
now returnsUBig
instead ofIBig
error::{OutOfBoundsError, ParseError}
are removed, related error types are added todashu-base
PartialOrd
andPartialEq
is not implemented for primitive integers any more. Please usenum_order::NumOrd
for comparison. (Seenum-bigint
#150)num-integer
feature is not enabled by default now.
- Add
sqrt
,sqrt_rem
,nth_root
forUBig
andIBig
- Implement
core::iter::{Sum, Product}
forUBig
andIBig
- Implement
num_traits::{Euclid, ToPrimitive, FromPrimitive}
forUBig
andIBig
- Implement
num_integer::{Integer, Roots}
forUBig
andIBig
- Implement
num_order::{NumHash, NumOrd}
forUBig
andIBig
- Implement
zeroize::Zeroize
forUBig
,IBig
and internal types serde
se/derialization now supports theis_human_readable()
flag
- Expose the
Sign
enum and related operations withUBig
andIBig
- Expose
DoubleWord
for easier operation withWord
- Add a public API
as_words
andas_sign_words
to access internal representation ofUBig
andIBig
respectively. - Add const constructors
from_word
,from_dword
and a direct constructorfrom_words
forUBig
. - Add a const constructor
from_parts_const
and a director constructorfrom_parts
forIBig
- Add
split_bits
andclear_high_bits
forUBig
. - Add
remove
forUBig
- Add
abs_cmp
,abs_eq
forIBig
. - Implement
Mul
betweenSign
andUBig
/IBig
. - Implement
DivRemAssign
forUBig
andIBig
, andDivRemAssign
is re-exported in theops
module. - Implement integer logarithm
ilog
and 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-macro
crate.
- Function
zero()
,one()
,neg_one()
are changed to associated constantsZERO
,ONE
,NEG_ONE
. - Function
gcd()
andextended_gcd()
ofUBig
andIBig
are changed to be associated functions ofGcd
andExtendedGCD
. - Parsing a string with unsupported radix will now return an Err instead of
panic!
. from_str_with_radix_prefix
now 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-int
in 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
Modulo
type. - Implemented
gcd
andextended_gcd
forUBig
andIBig
.
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.
- Division: trim the trailing zero words before division.
- GCD: trim the trailing zero words, and give the number of zeros as input to low-level algorithms.
- GCD: An idea of fast gcd check for rational number: don't do gcd reduction after every operation. For small numerators or denominators, we can directly do a gcd, otherwise, we first do gcd with a primorial that fits in a word, and only remove these small divisors. Further improvement: store a const divisor for the prime factors in the primorial, thus supports a fast factorial of the gcd result, and then divide with these const divisor.
- Power: implement a k-ary pow when exponent is too large (after lifting to at least a full word), this will store pre-computed 2^1~2^k powers. Maybe move this implementation to a separate module folder, and use the window selection function from modular pow.
- Logarithm: for very large est value, the est error can be large and there can be many fixing steps, we should use a similar strategy as the non_power_two formatter, using power sequence, or call log again on the target / est_pow