Skip to main content

Arithmetic and Comparison Operators

Arithmetic Operators

OperatorDescriptionExample
+AdditionTotal := A + B;
-SubtractionDelta := A - B;
*MultiplicationProduct := A * 5;
/DivisionAverage := Sum / Count;

You can use parentheses to control order of operations, just like in math:

Result := (Value1 + Value2) * 3;

When dividing integers, results are truncated (rounded down). Use REAL types if decimal precision is needed.

Comparison Operators

OperatorDescriptionExample
=Equal toIF Mode = 1 THEN
<>Not equal toIF State <> 0 THEN
<Less thanIF Temp < 100 THEN
>Greater thanIF Speed > Limit THEN
<=Less than or equalIF Level <= 50 THEN
>=Greater or equalIF Count >= Max THEN

Examples


// Add two values and scale the result
Result := (Value1 + Value2) * 3;

// Trigger an alarm if temperature exceeds 100
IF Temperature > 100 THEN
Alarm := 1;
END_IF;

// Check if count is not zero
IF Counter <> 0 THEN
Status := 1;
END_IF;

// Divide with decimal result
FlowRate := Volume / Duration; // Use REAL type for precision