Standard library / math/bits

bits.LeadingZeros32()

Counts zero bits before the most significant set bit; zero returns the word width. Expected stdout: '31\n'.

Formal Syntax & Structure

go syntaxgo
func LeadingZeros32(x uint32) int

Parameters & Attributes

NameTypeDescription
xuint32First input operand (or sole input if unary).

Return Value

int

Counts zero bits before the most significant set bit; zero returns the word width.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/bits")
func main() {  fmt.Println(bits.LeadingZeros32(1))}
Go Reference