User Guide
Operators 141
Operands
expression1 : Number - A number or expression to be shifted left.
expression2 : Number - A number or expression that converts to an integer from 0 to 31.
Returns
Number - The result of the bitwise operation.
Example
In the following example, the integer 1 is shifted 10 bits to the left:
x = 1 << 10 The result
of this operation is
x = 1024. This is because 1 decimal equals 1 binary, 1 binary shifted left
by 10 is 10000000000 binary, and 10000000000 binary is 1024 decimal. In the following
example, the integer 7 is shifted 8 bits to the left:
x = 7 << 8 The result of this operation is x
= 1792
. This is because 7 decimal equals 111 binary, 111 binary shifted left by 8 bits is
11100000000 binary, and 11100000000 binary is 1792 decimal. If you trace the following
example, you see that the bits have been pushed two spaces to the left:
// 2 binary == 0010
// 8 binary == 1000
trace(2 << 2); // output: 8
See also
>>= bitwise right shift and assignment operator, >> bitwise right shift
operator
, <<= bitwise left shift and assignment operator, >>> bitwise
unsigned right shift operator
, >>>= bitwise unsigned right shift and
assignment operator
<<= bitwise left shift and assignment operator
expression1 <<= expression2
This operator performs a bitwise left shift (<<=) operation and stores the contents as a result in
expression1. The following two expressions are equivalent:
A <<= B;
A = (A << B)
Availability: ActionScript 1.0; Flash Player 5
Operands
expression1 : Number - A number or expression to be shifted left.
expression2 : Number - A number or expression that converts to an integer from 0 to 31.