Operator: ROR

The IEC operator is used for bitwise rotation of an operand to the right.

Permitted data types: BYTE, WORD, DWORD, LWORD

erg := ROR(in,n)

CODESYS moves in n-times one bit to the right and adds the bit to the rightmost position from the left.

[Tip] Tip

The number of bits which CODESYS uses for this operation is defined by the data type of the in input variable. If this is a constant, then CODESYS uses the smallest possible data type. The data type of the output variables still does not influence this operation.

Example 121. Examples

The results for erg_byte and erg_word are different depending on the data type of the input variables, although the values of the in_byte and in_word input variables are the same.

ST

PROGRAM ror_st

VAR
 in_byte : BYTE := 16#45;
 in_word : WORD := 16#45;
 erg_byte : BYTE;
 erg_word : WORD;
 n: BYTE := 2;
END_VAR

erg_byte := ROR(in_byte,n); (* Result: 16#51 *)
erg_word := ROR(in_word,n); (* Result: 16#4011 *)

FBD

_cds_img_ror.png