3

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?

Nathan Koop
  • 23,941
  • 24
  • 88
  • 123
Dan
  • 787
  • 1
  • 7
  • 14
  • 1
    When you need to find out the features of a language, it is best to search for keywords like "reference", "operator", "statement", followed by the name of the language. That would solve the problem of looking for symbols. – Ates Goral Sep 17 '09 at 04:12

4 Answers4

2

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

brianreavis
  • 11,422
  • 3
  • 40
  • 50
1

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
  • 27,478
  • 6
  • 54
  • 75
1

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
  • 46,971
  • 12
  • 87
  • 103
0

Bitwise right shift

Looks like PHP has this operator too:

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

Jason Kresowaty
  • 15,657
  • 9
  • 56
  • 83