Operators > << (bitwise left shift)
<< (bitwise left shift)Syntax
expression1
<<
expression2
Arguments
expression1
A number, string, or expression to be shifted left.
expression2
A number, string, or expression that converts to an integer from 0 to 31.
Description
Operator (bitwise); converts expression1
and expression2
to 32-bit integers, and shifts all of the bits in expression1
to the left by the number of places specified by the integer resulting from the conversion of expression2
. The bit positions that are emptied as a result of this operation are filled in with 0. Shifting a value left by one position is the equivalent of multiplying it by 2.
Player
Flash 5 or later.
Example
The following example shifts the integer 1
ten 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.
This following example shifts the integer 7
eight 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.
See also
>>= (bitwise right shift and assignment)