Documentation ¶
Overview ¶
Package bitsCount counts bits in a integer
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitCountByTableLookup ¶
BitCountByTableLookup Counts number of bits in a 64-bit unsigned integer using table looking using array, approx 30x slower than "BitCount"
Example ¶
ExampleBitCountByTableLookup example counts bits in a 64 bit int using byte lookup table.
const a64bUInt uint64 = 0xC0FFEEBAACE0BABE a64IntBits := BitCountByTableLookup(a64bUInt) fmt.Printf("There are %d one-bits in 0x%X\n", a64IntBits, a64bUInt)
Output: There are 39 one-bits in 0xC0FFEEBAACE0BABE
func BitCountEachOne ¶
BitCountEachOne counts number of bits in unsigned integer by iterating over all bits, 2x slower than BitCountByTableLookup
Example ¶
ExampleBitCountEachOne example counts one-bits in a 64 bit int one bit at a time
const a64bUInt uint64 = 0xC0FFEEBAACE0BABE a64IntBits := BitCountEachOne(a64bUInt) fmt.Printf("There are %d one-bits in 0x%X\n", a64IntBits, a64bUInt)
Output: There are 39 one-bits in 0xC0FFEEBAACE0BABE
Types ¶
type CLI ¶
type CLI struct {
// contains filtered or unexported fields
}
CLI wrapper for *flag.FlagSet
func (CLI) DisplayHelp ¶
func (b CLI) DisplayHelp()
DisplayHelp prints help on command line for bits module
Click to show internal directories.
Click to hide internal directories.