erigon-pulse/cl/utils/math.go
2022-12-09 19:19:01 +01:00

13 lines
179 B
Go

package utils
func IsPowerOf2(n uint64) bool {
return n != 0 && (n&(n-1)) == 0
}
func PowerOf2(n uint64) uint64 {
if n >= 64 {
panic("integer overflow")
}
return 1 << n
}