I know how to use "encoding/binary" to convert 4 bytes to an int, etc.
What is the most efficient way to convert just 3 bytes to an int?
I know how to use "encoding/binary" to convert 4 bytes to an int, etc.
What is the most efficient way to convert just 3 bytes to an int?
Little endian:
n := int(uint(b[0]) | uint(b[1])<<8 | uint(b[2])<<16))
Big endian:
n := int(uint(b[2]) | uint(b[1])<<8 | uint(b[0])<<16))