Standard library / math/bits

bits.Len16()

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

Formal Syntax & Structure

go syntaxgo
func Len16(x uint16) (n int)

Parameters & Attributes

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