Attention
IronPLC supports IEC 61131-3 Structured Text excluding I/O mapping.
V4002¶
- Code
V4002
- Message
Negative exponent in arithmetic operation
The program attempted to raise a value to a negative exponent using the EXPT
function. IEC 61131-3 integer exponentiation does not support negative exponents.
Example¶
The following code will generate error V4002:
PROGRAM Main
VAR
x : INT := 5;
result : INT;
END_VAR
result := EXPT(x, -2); (* Error: negative exponent *)
END_PROGRAM
The exponent -2 is negative, which is not supported for integer exponentiation.
To fix this error, ensure the exponent is non-negative: