views:

199

answers:

5

I'm translating a JavaScript algorithm into PHP, and I ran into the symbol >>, and I have no clue what it means. It's hard to search Google for symbols, so can anyone tell me what it means?

A: 

Bitwise right shift

Looks like PHP has this operator too:

http://us2.php.net/operators.bitwise

binarycoder
+2  A: 

It's a bit shifting operator: http://www.contactor.se/~dast/fpl-old/language/shift.HTML

brianreavis
+1  A: 

It is a sign-propagating right shift. Many, many, languages have this operator.

Wikipedia has a good article on the subject. My first link has a few examples and an explanation.

Nick Presta
A: 

>>

This is the sign-propagating right shift operator which shifts the digits of the binary representation of the first operand to the right by the number of places specified by the second operand, discarding any shifted off to the right.

http://www.devguru.com/technologies/javascript/11502.asp

rick schott
+1  A: 

Other answers are correct, but this may be of help to you: If x is positive then

x >> y

is the same as

floor(x / (2 ** y))

where 2**y is 2 raised to the power y.

E.g. x >> 3 is the same as floor(x / 8).

Artelius