1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-03 00:57:52 +02:00
Files
lazygit/vendor/github.com/cloudflare/circl/math/integer.go
Stefan Haller 4cf49ff449 Bump go-git
2025-04-09 11:23:55 +02:00

17 lines
360 B
Go

package math
import "math/bits"
// NextPow2 finds the next power of two (N=2^k, k>=0) greater than n.
// If n is already a power of two, then this function returns n, and log2(n).
func NextPow2(n uint) (N uint, k uint) {
if bits.OnesCount(n) == 1 {
k = uint(bits.TrailingZeros(n))
N = n
} else {
k = uint(bits.Len(n))
N = uint(1) << k
}
return
}