SHR

Shifts a bit string right by a specified number of positions.

Signature

    ┌─────────┐
IN ─┤         │
    │   SHR   ├─ OUT
 N ─┤         │
    └─────────┘
FUNCTION SHR : ANY_BIT
  VAR_INPUT
    IN : ANY_BIT;
    N  : ANY_INT;
  END_VAR
END_FUNCTION

The return type matches the type of IN. SHR accepts BYTE, WORD, DWORD, LWORD for IN; N is INT.

Inputs

Name

Type

Description

IN

ANY_BIT

The bit string to shift.

N

ANY_INT

Number of positions to shift right.

Outputs

Name

Type

Description

Return value

ANY_BIT

IN shifted right by N positions, with zeros filled in on the left. Same type as IN.

Description

Shifts the bit string IN right by N positions. Vacated positions on the left are filled with zeros. Bits shifted beyond the rightmost position are discarded.

Example

result := SHR(WORD#16#FF00, 8);        (* result = 16#00FF *)

See Also

  • SHL — shift left

  • ROR — rotate right

  • ROL — rotate left

References