ABS¶
Returns the absolute value of a numeric input.
Signature¶
┌─────────┐
IN ─┤ ABS ├─ OUT
└─────────┘
FUNCTION ABS : ANY_NUM
VAR_INPUT
IN : ANY_NUM;
END_VAR
END_FUNCTION
The return type matches the input type. ABS accepts SINT,
INT, DINT, LINT, REAL, LREAL.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The numeric value to compute the absolute value of. |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
The non-negative magnitude of IN. Same type as IN. |
Description¶
Returns the absolute value of IN. For signed integer types, the result
of ABS applied to the most negative value is undefined because
the positive value cannot be represented.
Example¶
result := ABS(-42); (* result = 42 *)
value := ABS(REAL#-3.14); (* value = 3.14 *)
See Also¶
References¶
IEC 61131-3 §2.5.1.5.2