MAX¶
Returns the larger of two inputs.
Signature¶
┌─────────┐
IN1 ─┤ │
│ MAX ├─ OUT
IN2 ─┤ │
└─────────┘
FUNCTION MAX : ANY
VAR_INPUT
IN1 : ANY;
IN2 : ANY;
END_VAR
END_FUNCTION
The return type matches the input type. MAX accepts SINT,
INT, DINT, LINT, USINT, UINT, UDINT, ULINT,
REAL, LREAL. Both inputs must share the same type.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The first value to compare. |
|
|
The second value to compare. |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
The larger of IN1 and IN2. If both inputs are equal, returns that value. Same type as the inputs. |
Description¶
Returns the larger of IN1 and IN2. If both inputs are equal, the function returns that value.
Example¶
result := MAX(10, 20); (* result = 20 *)
result := MAX(-5, 3); (* result = 3 *)
See Also¶
References¶
IEC 61131-3 §2.5.1.5.5