Help/example of bit testing

Fran=?ISO-8859-1?B?5w==?=ois Granger fgranger at teleprosoft.com
Thu Dec 7 15:55:22 CET 2000


in article 90llq7$8fc at dispatch.concentric.net, Bryan Webb at
bww00 at amdahl.com wrote on 6/12/00 16:25:

> Hi,
> I am reading a file (binary)of 1024 char recs (bitmaps) . I can read the
> file , bit im having trouble finding examples of testing bits. I need to
> look at each bit of the above record.
> Looking for examples and ideas.

There is a summary here, which need improvement.

http://francois.granger.free.fr/MacPython/faq/MacPyBeg-Bitwise.html

quick and dirty

genMasq = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192,
16384, 32768]

data = 198

for i in range(7):
    if data & genMask[i]:
        print "bit" + str(i) + "is on"
-- 
François Granger
fgranger at altern.org




More information about the Python-list mailing list