Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript language elements > Operators > >>= bitwise right shift and assignment operator | |||
expression1 >>= expression2
This operator performs a bitwise right-shift operation and stores the contents as a result in expression1.
The following two statements are equivalent:
A >>= B; A = (A >> B);
Availability: ActionScript 1.0; Flash Player 5
expression1 : Number - A number or expression to be shifted right.
expression2 : Number - A number or expression that converts to an integer from 0 to 31.
Number - The result of the bitwise operation.
The following commented code uses the bitwise right shift and assignment (>>=) operator.
function convertToBinary(numberToConvert:Number):String {
var result:String = "";
for (var i = 0; i<32; i++) {
// Extract least significant bit using bitwise AND
var lsb:Number = numberToConvert & 1;
// Add this bit to the result
string result = (lsb ? "1" : "0")+result;
// Shift numberToConvert right by one bit, to see next bit
numberToConvert >>= 1;
}
return result;
}
trace(convertToBinary(479));
// Returns the string 00000000000000000000000111011111
// This string is the binary representation of the decimal
// number 479
>> bitwise right shift operator
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001260.html