# Arithmetic right shift

Arithmetic right shift, >>, is a bitwise operator to shift a binary value to the right, with sign extension.

 Availability BASIC V Syntax BASIC V = `>>` Token (hex) BASIC V `3E 3E` (operator) Description BASIC V Returns the first operand, with the bits of its binary representation shifted toward the least significant end by the number of places specified in the second operand, and the most significant bit copied into the vacant bits. Associated keywords `<<`, `>>>`, `AND`, `DIV`, `EOR`, `NOT`, `OR`

## Description

`>>` accepts two integer values, and returns the first value right-shifted by the number of binary places given in the second operand. For instance, in the statement

```PRINT ~&87654321 >> 4
```

the binary digits of &87654321, 10000111011001010100001100100001, are moved four places to the right in the register. In this case, the four least significant bits (0001) are discarded, and the sixteens' place (bit 4) becomes the units' place (bit 0) of the returned value. As it is an arithmetic shift, the most significant bit is duplicated four times, so that bits 27 to 31 of the result are the same - all 1s in this case. BASIC performs the shift in a single instruction, but if we consider the shift as a step-by-step calculation, it may be represented as:

```Operand    10000111011001010100001100100001
|\
1st shift  11000011101100101010000110010000 →
| \
2nd shift  11100001110110010101000011001000 →
|  \
3rd shift  11110000111011001010100001100100 →
|   \
4th shift  11111000011101100101010000110010 →
```

The output from the statement is:

```>PRINT ~&87654321 >> 4
F8765432
```