Skip to content

rsms/go-bits

Repository files navigation

bits

GitHub tag (latest SemVer) PkgGoDev Go Report Card

bit manipulation

// PopcountUint returns the number of bits set in v
func PopcountUint(v uint) int
func PopcountUint64(v uint64) int

// Bitindex is equivalent to PopcountUint(bmap&(bitpos-1))
func Bitindex(bmap, bitpos uint) int

// PopcountIsIntrinsic returns true if popcount is implemented with a dedicated CPU instruction
func PopcountIsIntrinsic() bool