Contents | Prev | Next
8.4.2.4 Subtraction (-)
Description
When the - operator has two operands of
integral type or
real type it performs subtraction, according to the
following rules:
First the numeric type conversion rules are applied.
After applying the numeric type conversion rules, the operands are either both of
integer type, or both of
word type or both of
real type, or both of
address type or one operand is of
address type and the other operand is not.
- If both operands are of integer type then unsigned
integer subtraction is performed, and the result is a value of
type integer.
- If both operands are of word type then unsigned
integer subtraction is performed, and the result is a value of
type word.
- If both operands are of real type then real (i.e
floating point) subtraction is performed, and the result is a value of
type real.
- If both operands are of address type then unsigned
integer subtraction is performed, and the result is a value of
type integer.
- If one operand is of address type and the other operand
is not then unsigned integer subtraction is performed, and the result is a value of
address type.
Example
Here are some examples using the - operator to perform subtraction:
3 - 5 which results in the integer value -2
3 - 5.0 which results in the real value -2.0
3.0 - 5 which results in the real value -2.0
3.0 - 5.0 which results in the real value -2.0
Contents | Prev | Next