Operators > >>= (bitwise right shift and assignment)
>>= (bitwise right shift and assignment)Syntax
expression1
=>>
expression2
Arguments
expression1
A number, string, or expression to be shifted left.
expression2
A number, string, or expression that converts to an integer from 0 to 31.
Description
Operator (compound assignment); this operator performs a bitwise right shift operation and stores the contents as a result in expression1
.
Player
Flash 5 or later.
Example
The following two expressions are equivalent:
A >>= B
A = (A >> B)
The following commented code uses the bitwise operator >>=
. It is also an example of using all bitwise operators.
function convertToBinary(number)
{
var result = "";
for (var i=0; i<32; i++) {
// Extract least significant bit using bitwise AND
var lsb = number & 1;
// Add this bit to our result string
result = (lsb ? "1" : "0") + result;
// Shift number right by one bit, to see next bit
}number >>= 1;
return result;
}
convertToBinary(479)
//Returns the string
00000000000000000000000111011111
//The above string is the binary representation of the decimal number 479.
See also
<< (bitwise left shift)