Contents | Prev | Next
8.2.2.4 Subtraction (-)
Description
When the - operator has two operands of
integral type or
real type it performs subtraction, according to the
following rules:
- If both operands are of integral type then integral subtraction is performed, and the
result is a value of integral type.
- If one operand is of integral type and the other is of real type then the integral
operand is converted into a real operand and real subtraction is performed, and the result
is a value of real type.
- If both operands are of real type then real subtraction is performed, and the result
is a value of real 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