Standard library / math/bits

bits.Len64()

Minimum number of bits needed to represent an unsigned value; zero has length zero. Expected stdout: '4\n'.

Formal Syntax & Structure

go syntaxgo
func Len64(x uint64) (n int)

Parameters & Attributes

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

Return Value

(n int)

Minimum number of bits needed to represent an unsigned value; zero has length zero.

Working Example

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