I have a data stream that is addressable only in 8-bit bytes, I want to parse it out into 6-bit elements and store that into an array. Is there any best known methods to do this?
11110000 10101010 11001100
into
an array like
111100|001010|101011|001100
(can have zero padding, just needs to be addressable this way)
and the data is an 8-bit array that is also a multiple of 6-bits , not really endless
Depends how much bits a byte has on your particular architecture. On a six bit architecture it is quite simple 🙂
Assuming a 8 bits per byte architecture you will have to do something along the lines:
Where n is the n-th 6 bit group. Any decent compiler will substitute the division with shifts and the moduli with ands. Just use this function in a loop to fill up your destination array.