Is there a way to deal with bits in c++(c is ok too!) in a way to emulate an encoder(or decoder) logic gate?
For example: encoding a byte(8 bits) into only 3 bits, or a word (16 bits) into 4 bits only and vise versa. exactly in the way encoder and decoder logic gate do it.
The goal of this is data compression (I know that there are better ways, but this is a single phase of the process and it must be done in this way for the project purposes)
Encoder Logic gate:
Decoder Logic gate:
Note: it can be done with bitwise operators but I need a really really fast and efficient way so that I can do it billions of times peer second!