note 36863 deleted from language.operators.bitwise by sniper
| From: | sniper@php.net | Date: | Wed, 29 Oct 2003 10:58:05 +0000 |
| Subject: | note 36863 deleted from language.operators.bitwise by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59464@lists.php.net to get a copy of this message | ||
Note Submitter: Eisnel
----
> I'm sorry but this example i just couldnt get i know
> this isnt the place to explain it but i read it here :)
Well, first of all:
49 XOR 57 = 8
It might be clearer in binary:
00110001 XOR 00111001 = 00001000
The result (8) contains only bits that are set in one but not both of the numbers.
Now, when they say "12" ^ "9", here's what they mean: That's an ASCII
"9", its ASCII code is 57. So saying "9" is the same as saying 57. As for the
"12", it will only use the first character, which is the "1", and the ASCII code
for "1" is 49. Therefore:
"12" ^ "9" == "1" ^ "9" == 49 ^ 57 == 8