General
Topics:
Intercept division by zero
To prevent runtime errors, a non-zero query should always be made before a division.
Static Analysis:
Check with the help of Static Analysis rule:
General program elements for the following samples:
FUNCTION F_Sample
VAR_INPUT
fDividend : LREAL;
fDivisor : LREAL;
END_VAR
VAR
fResult : LREAL;
END_VAR
Negative sample:
fResult := fDividend / fDivisor;
Positive sample:
IF fDivisor <> 0 THEN
fResult := fDividend / fDivisor;
END_IF