By calling isUnsignedPowerOfTwo instead of duplicating the same ones.
Change-Id: I1e29d3b7eda1bc8773fcd25728d8f508ae633ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/692916
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
}
// isUint64PowerOfTwo reports whether uint64(n) is a power of 2.
-func isUint64PowerOfTwo(in int64) bool {
- n := uint64(in)
- return n != 0 && n&(n-1) == 0
-}
+func isUint64PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint64(in)) }
// isUint32PowerOfTwo reports whether uint32(n) is a power of 2.
-func isUint32PowerOfTwo(in int64) bool {
- n := uint64(uint32(in))
- return n != 0 && n&(n-1) == 0
-}
+func isUint32PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint32(in)) }
// is32Bit reports whether n can be represented as a signed 32 bit integer.
func is32Bit(n int64) bool {