ADD¶
Returns the sum of two or more inputs.
Signature¶
┌─────────┐
IN1 ─┤ │
IN2 ─┤ ADD ├─ OUT
IN3 ─┤ │
└─────────┘
FUNCTION ADD : ANY_NUM
VAR_INPUT
IN1 : ANY_NUM;
IN2 : ANY_NUM;
(* ... additional inputs ... *)
END_VAR
END_FUNCTION
The return type matches the input type. ADD accepts SINT,
INT, DINT, LINT, USINT, UINT, UDINT, ULINT,
REAL, LREAL. All inputs must share the same type.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The first addend. |
|
|
The second addend. |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
The sum of IN1 and IN2. Same type as the inputs. |
Description¶
Returns the sum of IN1 and IN2. ADD(a, b) is the functional
form of the + operator: a + b. Both forms are equivalent.
For integer types, overflow behavior wraps around (modular arithmetic).
Example¶
result := ADD(10, 20); (* result = 30 *)
result := 10 + 20; (* result = 30, operator form *)
See Also¶
References¶
IEC 61131-3 §2.5.1.5.3