You are here: Re: [PHP] Bitwise operators « PHP « IT news, forums, messages
Re: [PHP] Bitwise operators

Posted by "Chris Boget" on 09/26/05 20:02

>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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация