Left Shift
The << operator
- takes a single value (1,2,4,8 bytes), treats as sequence of bits
- and a small positive integer x
- moves (shifts) each bit x positions to the left
- left-end bit vanishes; right-end bit replaced by zero
- result contains same number of bits as input
Example:
00100111 << 2 00100111 << 8
-------- --------
10011100 00000000
|
** undefined and not recommended for signed quantities.
|