uint
uint copied to clipboard
`base_convert`: Same trick as with `to_base_le`, find the largest power of base
On 2022-05-28 @recmo wrote in b0b5d54
“Mod names”:
Same trick as with to_base_le
, find the largest power of base
that fits u64
and accumulate there first.
base: u64,
digits: I,
) -> Result<Self, BaseConvertError> {
// OPT: Special handling of bases that divide 2^64, and bases that are
// powers of 2.
// OPT: Same trick as with `to_base_le`, find the largest power of base
// that fits `u64` and accumulate there first.
if base < 2 {
return Err(BaseConvertError::InvalidBase(base));
}
let mut result = Self::ZERO;
for digit in digits {