(no) fast boolean evaluation ? missing NOT
tjreedy at udel.edu
Fri Aug 3 21:11:00 CEST 2007
"Stef Mientki" <S.Mientki-nospam at mailbox.kun.nl> wrote in message
news:eb4fb$46b2f7a6$d443bb3a$21643 at news.speedlinq.nl...
| John Machin wrote:
| So now I'm left with just one question:
| for bitwise operations I should use &, |, ^
| for boolean operations I should use and, or, xor
| but after doing some test I find strange effects:
| >>> A = 4
| >>> B = 5
| >>> A and B
>>> B and A
| >>> A & B
| >>> A or B
>>> B or A
| >>> A | B
| So if I use the bitwise operation on integers,
| "and" changes into (bitwise) "or" and vise versa.
No, you hypnotised yourself by generalizing from insufficient data.
Repeat experiment with, for instance, 3 and 4 instead of 4 and 5. Then 3&4
= 0, 3|4 = 7.
More information about the Python-list