uint
uint copied to clipboard
`root`: The division can be turned into bit-shifts when the degree is a power of
On 2022-05-31 @recmo wrote in c1a0c34
“Merge pull request #97 from recmo/isqrt”:
The division can be turned into bit-shifts when the degree is a power of two.
let mut decreasing = false;
loop {
// OPT: This could benefit from single-limb multiplication
// and division.
//
// OPT: The division can be turned into bit-shifts when the degree is a power of
// two.
let division = result
.checked_pow(degree - 1)
.map_or(Self::ZERO, |power| self / power);
let iter = (division + Self::from(degree - 1) * result) / Self::from(degree);
match (decreasing, iter.cmp(&result)) {
From src/root.rs:59