Standard library / math/bits
bits.Len()
Minimum number of bits needed to represent an unsigned value; zero has length zero. Native uint width is architecture-dependent; local validation uses 64 bits. Expected stdout: '4\n'.
Formal Syntax & Structure
go syntaxgo
func Len(x uint) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | uint | First input operand (or sole input if unary). |
Return Value
int
Minimum number of bits needed to represent an unsigned value; zero has length zero. Native uint width is architecture-dependent; local validation uses 64 bits.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/bits")
func main() { fmt.Println(bits.Len(9))}