ROR
The IEC operator is used for bitwise rotation of an operand to the right.
Permitted data types: BYTE, WORD, DWORD, LWORD
Syntax: erg := ROR (in, n)
TwinCAT moves n times to the right by 1 bit and at the same time adds the bit with the extreme right position on the left.
The number of bits, which TwinCAT takes into account for the calculation, is determined by the data type of the input variable. If this is a constant, TwinCAT considers the smallest possible data type. The data type of the output variable has no effect on the arithmetic operation. |
Examples:
The results for nResByte and nResWord are different, depending on the data type of the input variable, despite the fact that the values of the input variables nInByte and nInWord are the same.
ST:
PROGRAM Ror_st
VAR
nInByte : BYTE:=16#45;
nInWord : WORD:=16#45;
nResByte : BYTE;
nResWord : WORD;
nVar : BYTE :=2;
END_VAR
nResByte := ROR(nInByte,nVar); (*Result: 16#51*)
nResWord := ROR(nInWord,nVar); (*Result: 16#4011*)
FBD: