SHR (shift right)

The SHR instruction shifts the 32 bits of an integer to the right and replicates the leftmost bit (significant bit) to fill the vacant bits.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the Micro810, L20E, L50E, and L70E controllers.
SHR
SHR
SHR
SHR parameters
Parameter
Parameter Type
Data Type
Description
EN
Input
BOOL
When set to true, the instruction is enabled.
  • TRUE: Execute the current computation.
  • FALSE: There is no computation.
Applies to ladder diagram programs.
IN
Input
DINT
Any integer value.
NbS
Input
DINT
Number of 1 bit shifts (in set [1..31]).
SHR
Output
DINT
Right shifted value. There is no effect if NbS <= 0. If a value of 0, replaces the most significant bit.
ENO
Output
BOOL
Enables output. Applies to ladder diagram programs.

SHR examples

SHR function block Diagram example
SHR function block Diagram example
SHR ladder diagram example
SHR ladder diagram example
SHR structured text example
SHR structured text example
(* ST Equivalence: *) result := SHR (register,1); (* register = 2#1100_1101_0011_0101 *) (* result = 2#0110_0110_1001_1010 *)
Results
Results
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal