I'm trying to understand this piece of code for returning how many zeroes a byte array is prefixed with but I'm not sure what 0x1 is. Google search isn't helpful, but I'm assuming 0x1
is returning the first bit? What are these called?
Also, I know this is a separate question but I don't think it warrants a new thread: I don't quite understand why we're nesting a loop here, bit shifting, and subtracting j from 7. Is this how the byte is transformed into binary?
IdLength := 32
func PrefixLen(count [IdLength]byte) int {
for i := 0; i < IdLength; i++ {
for j := 0; j < 8; j++ {
if (count[i]>>uint8(7-j))&0x1 != 0 {
return i*8 + j
}
}
}
return IdLength*8 - 1
}