CODESYS SHL

SHL is an IEC operator that shifts the bits of an operand to the left by a specified number of positions. It is written as erg := SHL(in, n), where in is the value to shift and n is the number of bit positions. The result is assigned to erg.

Source checked7/7 values · 2026-10-26

Specification

2 sources
Languageiec 61131 3
CodeSHL
GroupOperator
Syntaxerg := SHL (in, n)
DialectCODESYS

Parameters

NameDescription
inOperand which is shifted to the left
nNumber of bits to shift in to the left

Study notes

  • CODESYS uses the data type of the input variable in to determine how many bits are used for the operation.
  • If n exceeds the data type width, the target system determines padding for BYTE, WORD, DWORD, and LWORD operands: padding with zeros or n MOD <register size>.
  • Example: in_byte := 16#45 shifted by n := 2 gives erg_byte := 16#14; in_word := 16#0045 shifted by 2 gives erg_word := 16#0114.
↑↓ navigate↵ openesc close