Re: Bitwise operators

From: Date: Mon, 26 Sep 2005 17:02:56 +0000
Subject: Re: Bitwise operators
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-223207@lists.php.net to get a copy of this message
I tested; I don't want to waste peoples time. Rewriting the question: this outputs: c = 32 d = 0 The question is why?
First row is the bit's number and the second row is the bit's value: #8 | #7 | #6 | #5 | #4 | #3 | #2 | #1 --------------------------------------- 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 So your variable $a, which has a value of 4 starts out in the bit position of #3 with that bit turned on.. Shift it left 3 (value of $b) spaces and you end up with bit #6 getting turned on giving you a value of 32, which is what $c is echoing out. Shifting to the right 3 spaces from the same starting position nets you 0 with all the bits turned off. At least, I'm pretty sure that's right. thnx, Chris

« previous php.general (#223207) next »