Mail Archives: djgpp/1998/07/31/09:30:31
> I wonder how big a short int is (in bits) and if there are anything smaller
> then an unsigned char (1, 2, 4 bits). I also wonder if there is any command
> to read and write a single bit in a variable.
>
> Thanks in advance.
I don't know weather there are packed bit arrays in ANSI.
But one thing is clear. Even if there are, in most cases it's not very usefull
(with very rare exception)' cause for the iXX processor there is no way to set
a single bit despites the regular way with and(&) and or (|) and so you can do
in C also.
The sizeof operator will allways give you the size of the variable you are
using.
The n'th bit you get by (1<<n);
You can set it by var|=(1<<n);
You can wipe it by var&=~(1<<n);
So why messing around with bitwise variables.
Uwe
- Raw text -