Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

double angle-bracket?

137 views
Skip to first unread message

lawpoop

unread,
Aug 10, 2009, 11:16:43 AM8/10/09
to
What does the double angle bracket mean?

I found a code snippet in a book that reads like this:

for($string_size=1<<6; $string_size<=26176; $string_size+=1<<9)
{ ... }

And I had never seen << before.

Jerry Stuckle

unread,
Aug 10, 2009, 1:00:36 PM8/10/09
to

http://www.php.net/manual/en/language.operators.bitwise.php

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

lawpoop

unread,
Aug 10, 2009, 2:33:38 PM8/10/09
to
On Aug 10, 1:00 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:

>
> http://www.php.net/manual/en/language.operators.bitwise.php

Thanks, Jerry. What is this operator typically called? Actually, I
guess what I'm asking is, is there a common coding term for a '>>'
operator, and is its operation in php called bit-shifting?

J.O. Aho

unread,
Aug 10, 2009, 2:36:47 PM8/10/09
to

$a & $b And Bits that are set in both $a and $b are set.
$a | $b Or Bits that are set in either $a or $b are set.
$a ^ $b Xor Bits that are set in $a or $b but not both are set.
~ $a Not Bits that are set in $a are not set, and vice versa.
$a << $b Shift left Shift the bits of $a $b steps to the left (each step
means "multiply by two")
$a >> $b Shift right Shift the bits of $a $b steps to the right (each step
means "divide by two")

--

//Aho

Doug Miller

unread,
Aug 10, 2009, 4:03:32 PM8/10/09
to
In article <7eb7opF...@mid.individual.net>, "J.O. Aho" <us...@example.net> wrote:

>$a >> $b Shift right Shift the bits of $a $b steps to the right
> (each step means "divide by two")

Not quite. Divide by two _and discard any remainder_.

E.g. even though seven divided by four is 1.75, 7 >> 2 = 1

J.O. Aho

unread,
Aug 10, 2009, 5:00:05 PM8/10/09
to

I think the "" was there to strengthen that the divided by two wasn't entirely
true. It's not my words, just copy'n'paste from the manual.

--

//Aho

Doug Miller

unread,
Aug 10, 2009, 6:38:25 PM8/10/09
to

Just want to make sure that the OP doesn't come away with any mistaken
impressions, like supposing that 7 >> 2 and 7.0 / 4.0 might produce the same
result.

0 new messages