<< (bitwise left shift)
Availability
Flash Player 5.
Usage
expression1 << expression2
Parameters
expression1
expression2
Returns
A 32-bit integer.
Description
Operator (bitwise); converts
bits in
expression1
conversion of
expression2
filled in with 0 and bits shifted off the left end are discarded. Shifting a value left by one position
is the equivalent of multiplying it by 2.
Floating-point numbers are converted to integers by discarding any digits after the decimal point.
Positive integers are converted to an unsigned hex 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 hex
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.
The return value is interpreted as a two's complement number with sign, so the return value will
be an integer in the range -2147483648 to 2147483647.
For more information, see "Operator precedence and associativity" in Using ActionScript in Flash.
Example
In the following example, the integer 1 is shifted 10 bits to the left:
x = 1 << 10
The result of this operation is
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
shifted left by 8 bits is 11100000000 binary, and 11100000000 binary is 1792 decimal.
74
Chapter 2: ActionScript Language Reference
A number or expression to be shifted left.
A number or expression that converts to an integer from 0 to 31.
expression1
to the left by the number of places specified by the integer resulting from the
. The bit positions that are emptied as a result of this operation are
x = 1024
x = 1792
and
expression2
. This is because 1 decimal equals 1 binary, 1 binary
. This is because 7 decimal equals 111 binary, 111 binary
to 32-bit integers, and shifts all the
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?