Operator: - (Subtraction/Negation)

Top  Previous  Next

The - operator subtracts two integer or floating-point numbers and returns the result. It is also used to change the sign of a number (see below).

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  a : INT;
  b : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
  a := b - 10; // Subtract 10 from b and assign value to a
  ...
  b := -b; // Change sign of b
  ...
END;
 
END_PROGRAM;