tidb math 源码
tidb math 代码
文件路径:/br/pkg/utils/math.go
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package utils
// NextPowerOfTwo returns the smallest power of two greater than or equal to `i`
// Caller should guarantee that i > 0 and the return value is not overflow.
func NextPowerOfTwo(i int64) int64 {
if i&(i-1) == 0 {
return i
}
i *= 2
for i&(i-1) != 0 {
i &= i - 1
}
return i
}
相关信息
相关文章
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦