mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 10:32:19 +00:00
13 lines
179 B
Go
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
|
|
}
|