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 Reverse8() function which is used to find the reversed order of the value of a. To access Reverse8() function you need to add a math/bits package in your program with the help of the import keyword.
func Reverse8(a uint8) uint8
Parameters: This function takes one parameter of uint8 type, i.e., a.
Return Value: This function returns the value of a with its bits in reversed order.
Reverse order of 5: 10100000
Example 2 :
Reverse8(00001001) := 10010000 Reverse8(00001101) := 10110000
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.