You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
267 B

package plonky2_verifier
import (
"fmt"
"math/bits"
)
// Computes `log_2(n)`, panicking if `n` is not a power of two.
func log2Strict(n uint) int {
res := bits.TrailingZeros(n)
if n>>res != 1 {
panic(fmt.Sprintf("Not a power of two: %d", n))
}
return res
}