I’m programming network headers and a lot of protocols use 4 bits fields. Is there a convenient type I can use to represent this information?
The smallest type I’ve found is a BYTE. I must then use a lot of binary operations to reference only a few bits inside that variable.
Since the memory is byte-addressed, you can’t address any unit smaller than a single byte. However, you can build the
structyou want to send over the network and use bit fields like this: