EasyManua.ls Logo

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

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
148 ActionScript language elements
Example
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
See also
>> bitwise right shift operator
>>> bitwise unsigned right shift operator
expression1 >>> expression2
The same as the bitwise right shift (>>) operator except that it does not preserve the sign of the
original
expression because the bits on the left are always filled with 0.
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 - A number or expression to be shifted right.
expression2 : Number - A number or expression that converts to an integer between 0 and
31.

Table of Contents

Related product manuals