Bit-shift operators, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 471

Advertising
background image

L-force | PLC Designer

IEC Operators and additional norm extending functions



DMS 3.2 EN 02/2011 TD29

469

Example in ST:

Var1 := NOT 2#1001_0011

Example in FBD:

9.4

Bit-Shift Operators...

9.4.1

SHL

PLC Designer IEC operator: Bitwise left-shift of an operand : erg:= SHL (in, n)

in gets shifted to the left by n bits. If n > data type width, for BYTE, WORD and DWORD
will be filled with zeros. But if signed data types are used, like e.g. INT, then an
arithmetic shift will be executed in such cases, that means it will be filled with the
value of the topmost bit.

Note!

Please note, that the amount of bits, which is regarded for the arithmetic operation,
is pretended by the data type of the input variable !. If the input variable is a
constant the smallest possible data type is regarded. The data type of the output
variable has no effect at all on the arithmetic operation.

See in the following example in hexadecimal notation that you get different results
for erg_byte and erg_word depending on the data type of the input variable (BYTE
or WORD), although the values of the input variables in_byte and in_word are the
same.

Advertising