[cs23021] Unsigned number question

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Dec 5 13:44:04 EST 2010


> 
> I was wondering if one could make a class with a member variable that is an
> unsigned type with hundreds of digit places?

Apparently, you can. The specification states that sufficient number
of integral (standard) type memory locations will be allocated to hold
requested number of bits. That is:

	  unsigned myBitField:111;

is perfectly legal. Note, that bit fields may have portability issues
such as alignment in basic types, byte order, concurrent access,
etc. Here is an example of bit fields portability debates:

  http://bytes.com/topic/c/answers/212529-bitfield-structs-not-padded-size-int

Thanks,
-- 
Mikhail


More information about the cs23021-2 mailing list