ROR

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

Signature

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

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

Inputs

Name

Type

Description

IN

ANY_BIT

The bit string to rotate.

N

ANY_INT

Number of positions to rotate right.

Outputs

Name

Type

Description

Return value

ANY_BIT

IN rotated right by N positions, with bits wrapping from the rightmost to the leftmost position. Same type as IN.

Description

Rotates the bit string IN right by N positions. Bits shifted out of the rightmost position wrap around to the leftmost position. No bits are lost.

Example

result := ROR(WORD#16#000F, 4);        (* result = 16#F000 *)

See Also

  • ROL — rotate left

  • SHR — shift right

  • SHL — shift left

References