bits.Len() Function in Golang with Examples
Go language provides inbuilt support for bits to implement bit counting and manipulation functions for the predeclared unsigned integer types with the help of bits package. This package provides Len() function which is used to find the minimum number of bits required to represent a and the result is 0 for a == 0. To access Len() function you need to add a math/bits package in your program with the help of the import keyword.
func Len(a uint) int
Parameters: This function takes one parameter of uint type, i.e., a.
Return Value: This function returns the minimum number of bits required to represent a.
The minimum number of bits required to represent 3: 2
Len(10) = 2 Len(1100) = 4
My Personal Notes arrow_drop_up
Please Login to comment...