Shift Left: SHL and Shift Right: SHR
- Last UpdatedNov 07, 2016
- 1 minute read
Shifts the binary representation of an integer value to the right or left by a specified number of bit positions. The left operand is the value to be shifted, the right operand is the number of bit positions. Bits shifted out of the word are lost. Bit positions vacated by the shift are set to 0.
Valid operands
Any Integer value.
Data type of return value
Integer
Example
IntTag = IntTag SHL 1; has the following results when executed repeatedly for an initial tag value of 5:
|
Iteration |
Binary pattern |
Tag value |
|---|---|---|
|
Initial value |
0[...]00000101 |
5 |
|
Execution 1 |
0[...]00001010 |
10 |
|
Execution 2 |
0[...]00010100 |
20 |