# Shr

From Free Pascal wiki

│
**Deutsch (de)** │
**English (en)** │
**français (fr)** │
**русский (ru)** │

Back to Reserved words.

## Overview

The reserved word **Sh**ift **r**ight (shr) performs a logical right bit-shift operation (opposite than shl).

## Shr with signed types

Note: unlike the >> operator in the C language, the shr operator is a logical (not arithmetic) bit shift, even if the left operand is a signed integer. An implicit typecast and extension to a larger unsigned type may be performed before the shift operation. Check what the following program actually prints.

```
program ShrTest;
begin
WriteLn(ShortInt(-3) shr 1);
end.
```

## Is a bit set

```
function isBitSet(AValue, ABitNumber:integer):boolean;
begin
result:=odd(AValue shr ABitNumber);
end;
```

## See also

- Boolean
- § “boolean operators” in the “Free Pascal Reference Guide”
- § “logical operators” in the “Free Pascal Reference Guide”
`and`

Bitwise and`or`

Bitwise or`not`

Bitwise negation (unary)`shl`

Bitwise shift to the left`shr`

Bitwise shift to the right`xor`

Bitwise xor`odd`

Determine if number is odd- << Bitwise shift to the left (same as shl)
- >> Bitwise shift to the right (same as shr)
- $Bitpacking
- Bit manipulation

}}