Documentation ¶
Overview ¶
Package bits provides utils for manipulation bits of a single byte
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructByteOfQuarters ¶
ConstructByteOfQuarters constructs a byte of it's four quarters given
Example ¶
fmt.Printf("%08b", ConstructByteOfQuarters(3, 2, 1, 3)) // 00000011 00000010 00000001 00000011 in binary
Output: 11100111
func ConstructByteOfQuartersAsSlice ¶
ConstructByteOfQuartersAsSlice constructs a byte of it's four quarters given as byte slice
Example ¶
var quarters = []byte{3, 2, 1, 3} // 00000011 00000010 00000001 00000011 in binary fmt.Printf("%08b", ConstructByteOfQuartersAsSlice(quarters))
Output: 11100111
func GetLastTwoBits ¶
GetLastTwoBits returns byte containing only last two bits of given byte
Example ¶
fmt.Printf("%08b", GetLastTwoBits(134)) // 134 is 10000110 in binary
Output: 00000010
func QuartersOfByte ¶
QuartersOfByte returns a byte's four quarters of bits
Example ¶
fmt.Printf("%08b", QuartersOfByte(231)) //231 is 11100111 in binary
Output: [00000011 00000010 00000001 00000011]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.