![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Flash Player 5.
expression1
=>>expression2
expression1
A number or expression to be shifted left.
expression2
A number or expression that converts to an integer from 0 to 31.
Nothing.
Operator (bitwise compound assignment); this operator performs a bitwise right-shift operation and stores the contents as a result in expression1
.
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;
}
trace(convertToBinary(479));
// Returns the string 00000000000000000000000111011111
// The above string is the binary representation of the decimal
// number 479
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |