Working with raw binary digits.

Inyeol Lee inyeol.lee at siimage.com
Thu Feb 27 22:21:10 CET 2003


> If you want to use individual bits, just use 0 and 1, and the
> logical operators 'and', 'or', and 'not'.  Roll your own nand,
> nor, etc., in terms of these.
> 
> If you want to apply such operators to bit strings, use the
> bitwise operators &, | and ~.  Roll your own nand, nor, etc., in
> terms of these.

Just a comment. If you use integer 0 and 1, be carefule using ~
operator. Use ^ instead for bit negation.

>>> ~1
-2
>>> ~0
-1
>>> 1 ^ 1
0
>>> 0 ^ 1
1

Inyeol...






More information about the Python-list mailing list