DavidCrow wrote:
Something like: struct{ char c:4;};
This is indeed a respected method inkeeping with the language. However it also depends on what the four bit data type is to be used for, Is packing on a Four Bit boundary required.If a lot of manipulating code is to be written, or an array of nibbles needs to be addressed, maybe a more transparent way is Masking and Shifting, and a Raft of Macro's to cover it. e.g.: #define LO_NIBBLE(x) ((x)&0xFF) #define HI_NIBBLE(x) (((x)>4))&0xFF) #define GET_ARR_ITEM(Arr,N) ((((N)&1)==0)?LO_NIBBLE((Arr)[(N)/2]:HI_NIBBLE((Arr)[(N)/2]) And so on ad infinitum Even further, depending on the importance and complexity of the grander problem to be solved, (and the Time and resources available)one could conceive of a new class, CNibble with an entire gammet of overloaded operators. Come to think of it, why not also a Class CHalfNibble and CBit. Hope this is of help, :) regards
LateNightsInNewry