OR¶
Returns the bitwise OR of two or more inputs.
Signature¶
┌─────────┐
IN1 ─┤ │
IN2 ─┤ OR ├─ OUT
IN3 ─┤ │
└─────────┘
FUNCTION OR : ANY_BIT
VAR_INPUT
IN1 : ANY_BIT;
IN2 : ANY_BIT;
(* ... additional inputs ... *)
END_VAR
END_FUNCTION
The return type matches the input type. OR accepts BOOL,
BYTE, WORD, DWORD, LWORD. All inputs must share the same
type.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The first operand. |
|
|
The second operand. |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
Each bit set in any input. Same type as the inputs. |
Description¶
On BOOL inputs, returns TRUE when at least one input is TRUE.
On BYTE, WORD, DWORD and LWORD inputs, each bit of the
result is set when the same bit is set in any input. OR(a, b) is the
functional form of the OR operator: a OR b. Both forms are
equivalent, and OR(a, b, c) is a OR b OR c.
Example¶
result := OR(WORD#16#F0F0, WORD#16#FF00); (* result = 16#FFF0 *)
result := WORD#16#F0F0 OR WORD#16#FF00; (* operator form *)
result := OR(WORD#16#F0F0, WORD#16#FF00, WORD#16#000F); (* result = 16#FFFF *)
See Also¶
AND — bitwise AND
XOR — bitwise exclusive OR
NOT — bitwise complement
Logical Operators — the operator forms
References¶
IEC 61131-3 §2.5.1.5.3