8.5
Logical functions
Boolean variables are linked logically, UINT and UDINT variables are linked bit-by-bit.
If there are more than two parameters, each pair is always linked from left to right.
Admissible data types
Operand: BOOL, UINT, UDINT
Result: BOOL, UINT, UDINT
AND
AND link
Examples:
Logical link:
x := TRUE;
y := FALSE;
z := x AND y; (* z = FALSE *)
Bit-by-bit link:
a := 5;
b := 6;
c := a AND b; (* 0100 = 4 *)
OR
OR link
Examples:
Logical link:
x := TRUE;
y := FALSE;
z := x OR y; (* z = TRUE *)
Bit-by-bit link:
a := 5;
b := 6;
c := a OR b; (* 0111 = 7 *)
XOR
Exclusive OR link
Examples:
Logical link:
x := TRUE;
y := FALSE;
z := x XOR y; (* z = TRUE *)
Bit-by-bit link:
a := 5;
b := 6;
c := a XOR b; (* 0011 = 3 *)
(* 0101 *)
(* 0110 *)
(* 0101 *)
(* 0110 *)
(* 0101 *)
(* 0110 *)
8 Functions
41