Standard library / math/bits

bits.OnesCount16()

Counts set bits (population count) in the unsigned word. Expected stdout: '3\n'.

Formal Syntax & Structure

go syntaxgo
func OnesCount16(x uint16) int

Parameters & Attributes

NameTypeDescription
xuint16First 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.OnesCount16(11))}
Go Reference