Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Subtraction

&pagelevel(5)&pagelevel

The subtraction operator is the minus sign (-).

Rules:

For the minus sign as an operator in a subtraction operation:

  • The minus sign must be preceded or followed by a space so that it will not be mistaken for a hyphen (see example).

  • The result value must be greater than or equal to -231 and less than or equal to 231-1.

For the minus sign as a negative sign:

  • The minus sign must be preceded by a space.

  • The minus sign must be directly followed by the numeric literal or variable name.

Example

/A = -45
/B = -45 - 5
/C = A - B
/D = A-B

All these assignments are syntactically correct: variables A, B and C are assigned integer values (-45, -50, 5) and variable D is assigned the contents of a variable A-B, assuming this variable is declared and initialized. If there is no variable with the name A-B or if it is not initialized, this assignment results in an error.