Node:shr, Next:Sin, Previous:ShortWord, Up:Reference

### shr

#### Synopsis

    operator shr (operand1, operand2: integer_type) = Result: integer_type;

or

    procedure shr (var operand1: integer_type; operand2: integer_type);

#### Description

In GNU Pascal, `shr` has two built-in meanings:

1. Bitwise shift right of an integer-type expression by another integer value. The result is of the type of the first operand.
2. Use as a "procedure": `operand1` is shifted right by `operand2`; the result is stored in `operand1`.

#### Conforming to

`shr` is a Borland Pascal extension.

Unlike the Borland compilers, GNU Pascal cares about the signedness of the first operand: If a signed integer with a negative value is shifted right, "one" bits are filled in from the left.

Use of `shr` as a "procedure" is a GNU Pascal extension.

#### Example

    program ShrDemo;
    var
      a: Integer;
    begin
      a := 1024 shr 4;  { yields 64 }
      a := -127 shr 4;  { yields -8 }
      shr (a, 2)  { same as `a := a shr 2' }
    end.

#### See also

Keywords, shl, Operators.