`SHR=`

Operator

Does a right-shift operation on the bits of a variable, then changes the variable to the result.

## Syntax

```
variable SHR= number
```

## Parts

`variable`

- An integer variable.
`number`

- An integer expression that specifies the number of bits to shift.

## Instructions

The two statements that follow are equivalent.

```
variable SHR= number
variable = variable SHR number
```

The element on the left side of `SHR=`

can be a scalar variable, a property, or an element of an array.
A property cannot have the modifier `@ReadOnly`

.

SHR= does a right-shift operation on the value of the variable or property on its left side. The bits move right by the number given on the right side expression. Then it changes the variable or property on its left side to the result.

If the variable or property has an unsigned type, `SHR=`

does a logical right shift.
Such types include `UInt8`

, `UInt16`

, `UInt32`

, `UInt64`

, and `UInt128`

.
The bits on the left side become zeroes, while the bits on the right side are discarded.

If the variable or property has a signed type, `SHR=`

does an arithmetic right shift.
Such types include `Int8`

, `Int16`

, `Int32`

, `Int64`

, and `Int128`

.
The bits on the left side copy the sign bit, while the bits on the right side are discarded.

## Examples

```
a = %B1010_1000
b = a
a SHR= 2
b SHR= 4
```

Variable | Value |
---|---|

`a` |
42 (00101010) |

`b` |
6 (00001010) |