Getting at the bits of a 32-bit integer
jacobsmail at postmark.net
Tue Aug 24 01:52:07 CEST 2004
Hi there list,
I'm a beginning programmer, so please correct me if any of the
following assumptions are wrong.
Suppose I have the decimal number 255. Since integers in Python are 32
bits, it would look like this in binary:
00000000 00000000 00000000 11111111
There are plenty of unused bits to the left of the number itself. If I
wanted to use some of these bits as true/false flags, how would I go
about it? In Python, how do I write code that gets at the leftmost
byte, or the third bit from the left of the set of 32, or the
rightmost byte plus the bit to its left, etc...
Thanks in advance for any help on this. :)
More information about the Python-list