note 66452 deleted from language.operators.bitwise by nlopess
| From: | nlopess@php.net | Date: | Tue, 23 May 2006 21:55:36 +0000 |
| Subject: | note 66452 deleted from language.operators.bitwise by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-111901@lists.php.net to get a copy of this message | ||
Note Submitter: riseofthethorax at earthlink dot net
----
Bitwise operators and boolean operations are not the same. Booleans can work on individual bits, but
not on bytes. A byte contains 8 bits. If you do 1 && 0 you will get 0, but if
you do 7 && 0 you will also get 0, because internally
anything that is non-zero is true, and zero is false. So 5 && 2 is 1.. But if you do 5 &
2, noticed one ampersand not two, which in binary is 101, 010, bit-wise and, will get you 111, or 7.
Do a search on the net for "truth tables bit operators XOR AND NOT OR", or shorten it to
"truth tables XOR" and hunt down pages with truth tables for bit operations. For instance
I fount this page:
http://andercheran.aiind.upv.es/~amstrad/docs/logic.html