SHR¶
Shifts a bit string right by a specified number of positions.
Signature¶
┌─────────┐
IN ─┤ │
│ SHR ├─ OUT
N ─┤ │
└─────────┘
FUNCTION SHR : ANY_BIT
VAR_INPUT
IN : ANY_BIT;
N : ANY_INT;
END_VAR
END_FUNCTION
The return type matches the type of IN. SHR accepts BYTE,
WORD, DWORD, LWORD for IN; N is INT.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The bit string to shift. |
|
|
Number of positions to shift right. |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
IN shifted right by N positions, with zeros filled in on the left. Same type as IN. |
Description¶
Shifts the bit string IN right by N positions. Vacated positions on the left are filled with zeros. Bits shifted beyond the rightmost position are discarded.
Example¶
result := SHR(WORD#16#FF00, 8); (* result = 16#00FF *)
See Also¶
References¶
IEC 61131-3 §2.5.1.5.6