Re: Bitwise operators
| From: | cron at odi dot com dot br | Date: | Mon, 26 Sep 2005 17:16:59 +0000 |
| Subject: | Re: Bitwise operators | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-223208@lists.php.net to get a copy of this message | ||
The second value is the number of spaces to shift, dint realize that.
Thanks for your time Chris.
Angelo
----- Original Message -----
From: "Chris Boget" <chris.boget@wild.net>
To: <cron@odi.com.br>; <php-general@lists.php.net>
Sent: Monday, September 26, 2005 2:02 PM
Subject: Re: [PHP] Bitwise operators
> >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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>