mirror of
https://github.com/containerd/containerd.git
synced 2026-11-06 13:27:16 +00:00
Bumps [github.com/containerd/imgcrypt/v2](https://github.com/containerd/imgcrypt) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/containerd/imgcrypt/releases) - [Changelog](https://github.com/containerd/imgcrypt/blob/main/CHANGES) - [Commits](https://github.com/containerd/imgcrypt/compare/v2.0.2...v2.0.3) --- updated-dependencies: - dependency-name: github.com/containerd/imgcrypt/v2 dependency-version: 2.0.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
17 lines
360 B
Go
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
|
|
}
|