uint icon indicating copy to clipboard operation
uint copied to clipboard

`base_convert`: Same trick as with `to_base_le`, find the largest power of base

Open github-actions[bot] opened this issue 2 years ago • 0 comments

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 {

From src/base_convert.rs:82

github-actions[bot] avatar May 28 '22 18:05 github-actions[bot]