<Syntax> |
|
+ expression |
|
|
- expression |
|
|
expression + expression |
|
|
expression - expression |
|
|
expression * expression |
|
|
expression / expression |
|
|
expression ** expression |
|
|
These operators have their usual
mathematical precedence, and have higher precedence than any other operator
except for unary user-defined operators.
|
|
<Semantics> |
|
Numeric operations.
The expressions must be of type Complex, Integer or Real.
The unary + and - operators return the same type and kind as their operators;
the value of the + operator is the same as that of the expression, and the
value of the - operator is the negation of the expression.
The binary +, -, *, / and ** operators perform addition, subtraction,
multiplication, division and exponentiation respectively.
If both expressions are of type Integer, the result has the same kind as the
expression with the largest range.
If one expression is of type Integer and the other expression is Complex or
Real, the result has the same type and kind as the other expression.
If both expressions are of type Real, the result is type Real and has the same
kind as the expression with the largest precision.
These rules are illustrated in the table below.
|
|
|
Result of numeric operation op1
op op2 |
Type of op1 |
|
Type of op2 |
|
Result type |
|
Result kind |
Complex |
|
Complex |
|
Complex |
|
largest precision |
Complex |
|
Integer |
|
Complex |
|
KIND(op1) |
Complex |
|
Real |
|
Complex |
|
largest precision |
Integer |
|
Complex |
|
Complex |
|
KIND(op2) |
Integer |
|
Integer |
|
Integer |
|
largest range |
Integer |
|
Real |
|
Real |
|
KIND(op2) |
Real |
|
Complex |
|
Complex |
|
largest precision |
Real |
|
Integer |
|
Real |
|
KIND(op1) |
Real |
|
Real |
|
Real |
|
largest precision |
|
|
|
|
|
<Related> |
|
|
.AND. operator,
Concatenation (//) operator,
.EQ. (==) operator,
.EQV. operator,
.GE. (>=) operator,
.GT. (>) operator,
.LE. (<=) operator,
.LT. (<) operator,
.NE. (/=) operator,
.NEQV. operator,
.NOT. operator,
Operator precedence,
.OR. operator |
|
|