8 Functions
8.4
Bit sequence functions
Admissible data types
Argument: UINT, UDINT
Result: UINT, UDINT
SHL (IN, n)
Moves the bit sequence of the IN argument to the left by n bits. Subsequent digits are filled with 0 from
the right.
Example:
IN := 255;
OUT := SHL(IN, 4); (* 0000 1111 1111 0000; OUT = 4080 *)
SHR (IN, n)
Moves the bit sequence of the IN argument to the right by n bits. Subsequent digits are filled with 0 from
the left.
Example:
IN := 255;
OUT := SHR(IN, 4); (* 0000 0000 0000 1111; OUT = 15 *)
ROL (IN, n)
Rotates the bit sequence of the IN argument to the left by n bits in a circle.
Example:
IN := 43690;
OUT := ROL(IN, 1); (* 0101 0101 0101 0101; OUT = 21845 *)
ROR (IN, n)
Rotates the bit sequence of the IN argument to the right by n bits in a circle.
Example:
IN := 21845;
OUT := ROR(IN, 1); (* 1010 1010 1010 1010; OUT = 43690 *)
40
(* 0000 0000 1111 1111 *)
(* 0000 0000 1111 1111 *)
(* 1010 1010 1010 1010 *)
(* 0101 0101 0101 0101 *)