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 TrailingZeros16() function which is used to find the number of trailing zero bits in a and the result is 16 for a == 0. To access TrailingZeros16() function you need to add a math/bits package in your program with the help of the import keyword.
func TrailingZeros16(a uint16) int
Parameters: This function takes one parameter of uint16 type, i.e., a.
Return Value: This function returns total number of trailing zero bits in a.
Total number of trailing zero bits in 15: 0
TrailingZeros16(0000000000001000)) := 3 TrailingZeros16(0000000000001101) := 0
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.