Bitwise Unsigned Right Shift Operator - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

Example
The following commented code uses the bitwise right shift and assignment (
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
See also
>> bitwise right shift operator
>>> bitwise unsigned right shift operator
expression1 >>> expression2
The same as the bitwise right shift (
original
expression
Floating-point numbers are converted to integers by discarding any digits after the decimal
point. Positive integers are converted to an unsigned hexadecimal value with a maximum
value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most
significant digits discarded when they are converted so the value is still 32-bit. Negative
numbers are converted to an unsigned hexadecimal value via the two's complement notation,
with the minimum being -2147483648 or 0x800000000; numbers less than the minimum
are converted to two's complement with greater precision and also have the most significant
digits discarded.
Availability: ActionScript 1.0; Flash Player 5
Operands
expression1 : Number
expression2 : Number
31.
148
ActionScript language elements
) operator except that it does not preserve the sign of the
>>
because the bits on the left are always filled with 0.
- A number or expression to be shifted right.
- A number or expression that converts to an integer between 0 and
) operator.
>>=

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents