Attention

IronPLC supports IEC 61131-3 Structured Text excluding I/O mapping.

V4001

Code

V4001

Message

Divide by zero during program execution

The program attempted to divide by zero at runtime. Integer division and modulo operations (DIV, MOD) fail when the divisor is zero.

Example

The following code will generate error V4001:

PROGRAM Main
VAR
    a : INT := 10;
    b : INT := 0;
    result : INT;
END_VAR
result := a / b;  (* Error: division by zero *)
END_PROGRAM

The variable b is zero, so the division operation cannot be performed.

To fix this error, guard division operations with a check for zero: