Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does >> mean in PHP?

Consider:

echo 50 >> 4;

Output:

3

Why does it output 3?

like image 871
user198729 Avatar asked May 07 '10 17:05

user198729


People also ask

What does << mean in PHP?

It is the bitwise shift operator. Specifically, the left-shift operator. It takes the left-hand argument and shifts the binary representation to the left by the number of bits specified by the right-hand argument, for example: 1 << 2 = 4.

What is the meaning of >> operator?

The right shift operator ( >> ) returns the signed number represented by the result of performing a sign-extending shift of the binary representation of the first operand (evaluated as a two's complement bit string) to the right by the number of bits, modulo 32, specified in the second operand.

What is >> in bitwise?

>> Indicates the bits are to be shifted to the right. Each operand must have an integral or enumeration type. The compiler performs integral promotions on the operands, and then the right operand is converted to type int .

What does >> indicate in C?

Bitwise Right shift operator >> is used to shift the binary sequence to right side by specified position.


1 Answers

50 in binary is 11 0010, shift right by 4 yields 11 which is equal to 3.

See PHP documentation and Wikipedia.

like image 168
nevets1219 Avatar answered Sep 23 '22 00:09

nevets1219