Standard library / math/bits
bits.OnesCount64()
Counts set bits (population count) in the unsigned word. Expected stdout: '3\n'.
Formal Syntax & Structure
go syntaxgo
func OnesCount64(x uint64) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | uint64 | First input operand (or sole input if unary). |
Return Value
int
Counts set bits (population count) in the unsigned word.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/bits")
func main() { fmt.Println(bits.OnesCount64(11))}