You are here: Core Reference > Coding > Logic > ROR

ROR

Function Name

ROR (Rotate Right)

Description

Rotates each bit n positions to the right. So, rotating by 1 means the first bit in the string becomes the second bit in the string, the second bit becomes the third bit and so on. The last bit becomes the new first bit in the string.

Arguments

IN {ANY_BIT}

IN is a bit string.

N {ANY_INT}

N is an integer that defines the number of positions the ROR function will move the characters.

For more information on the data types for the inputs and outputs, see Data Type Hierarchy.

Returns

Output {Same data type as input}

The Output is the number that represents the new binary string.

Example:

Function Block Diagram - ROR:

The ROR function has two inputs. The top input (IN) is 146 which corresponds to the binary string of 10010010. The bottom input (N) is 3 which instructs the function to rotate the bits right by 3 positions. The output is 84 which corresponds to the binary string 10010100.

So, the rotate right function has rotated the bits 3 positions to the right:

Input String

10010010

Rotation Right x3

10100100

The binary string that results from 3 rotations right is 01010010 which corresponds to the decimal value of 84. So the value of the output is 84.

ST Program - ROR:

The ROR function is used to rotate the positions of the bits in the Input string to the right:

  • Output := ROR (IN, N);

Where Output, IN, and N are defined as variables earlier in the ST program.

Alternatively, you can use the following syntax:

  • Output := ROR (IN:= 146, N:= 3);

Where the numbers are the input values (in this case, they are the same numbers as used in the Function Block Diagram example).


ClearSCADA 2015 R2