Skip to main content

7.5.1 SHR

Function

Move the operand input by IN to the right by N bits in binary digits, and fill the vacant bits on the left with zeros. Finally, the result is output in OUT

LD graphics

alt text

  • The following figure illustrates how to shift the integer data type operand to the right by 2 bits:

alt text

Parameter description

Interface variableDeclarationData typeDescription
INVar_InputANY_BITOperand to be shifted right
NVar_InputANY_INTNumber of digits to shift to the right
Function nameReturn valueANY_BITValue after right shift
warning
  • Here ANY_BIT data type is BYTE, WORD, DWORD, LWORD;
  • BOOL has no meaning, the return value type is the same as IN type

Example

  • LD example is shown below:

alt text

  • ST example is shown in the following code:
wVar:=SHR(IN:=wVar,N:=nVar);