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 TrailingZeros() function which is used to find the number of trailing zero bits in a and the result is UintSize for a == 0. To access TrailingZeros() function you need to add a math/bits package in your program with the help of the import keyword.
func TrailingZeros(a uint) int
Parameters: This function takes one parameter of uint type, i.e., a.
Return Value: This function returns total number of trailing zero bits in a.
Total number of trailing zero bits in 6: 1
Example 2 :
TrailingZeros(1000)) := 3 TrailingZeros(1101) := 0