Bits to byte conversion
for my project, there is a part where i need to write an inner class called writeBuffer, and it is used to buffer bits, and it does for example, if you want to only write 3 bits at a time, it will store these 3 bits until you have at least 8 bits to write, and then output a byte. Have no idea how to do this at all, any pointers will be great, please and thank you!
Use the AND operator to isolate the bit, use the shift operator to move the bit to the slot where it goes and the OR operator to set the bit in a byte.
There would need to be a variable that has the "index" (7-0) for where the next bit should be set. Assumes bits output high to low.