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
| Name | Type | Description |
|---|---|---|
| x | uint16 | First 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))}