What does the << Operator mean in php?
Example:
$t = 5; $foo = 1 << ($t); echo($foo);
echo produces: 32
The left shift operator ( << ) shifts the first operand the specified number of bits, modulo 32, to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.
The >> operator is called a binary right shift operator. Shifting bits to the right 4 times is the same as dividing by two, four times in a row. The result, in this case would be 3.125 . Since 50 is an int, bit shifting will return the floor of this, which is 3 .
The bitwise shift operators are the right-shift operator ( >> ), which moves the bits of an integer or enumeration type expression to the right, and the left-shift operator ( << ), which moves the bits to the left.
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
because 1 (decimal) is 1 (binary); left-shift twice makes it 100
which is 4
in decimal.
1 << 5 = 32
because 100000
in binary is 32
in decimal.
Right shift (>>) does the same thing but to the right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With