Complex expressions are expressions that return complex values (arithmetic values that consist of a real part and an imaginary part) by applying specified operations to designated complex primaries.
<complex expression>
──┬─<arithmetic expression>──────────┬─────────────────────────────────┤ ├─<simple complex expression>──────┤ ├─<conditional complex expression>─┤ └─<try complex expression>─────────┘
<simple complex expression>
┌◄─ <complex operator> ─┐ ──┴─<complex primary>─────┴────────────────────────────────────────────┤
<complex operator>
──┬─ + ─┬──────────────────────────────────────────────────────────────┤ ├─ - ─┤ ├─ * ─┤ └─ / ─┘
<complex primary>
──┬─<arithmetic primary>───────────────────────────────┬───────────────┤
└─<complex operand>─┬────────────────────────────────┤
│ ┌◄───────────────────────────┐ │
└─┴─ ** ──<arithmetic primary>─┴─┘
<complex operand>
──┬─<complex variable>─┬─────────────────────────┬─────────────────────┤ │ ├─ := ──<complex primary>─┤ │ └─<update symbols>────────┤ ├─<complex function designator>────────────────┤ ├─ ( ──<complex expression>── ) ───────────────┤ └─<complex case expression>────────────────────┘
<complex case expression>
┌◄───────── , ─────────┐ ──<case head>── ( ─┴─<complex expression>─┴─ ) ────────────────────────┤
<conditional complex expression>
──<if clause>──<complex expression>── ELSE ──<complex expression>──────┤
<try complex expression>
── TRY ─┬─<try limited form>────────┬──────────────────────────────────┤
└─<try complex normal form>─┘
<try complex normal form>
┌◄─────────────────────────────┐ ──<complex expression>─┴─ ELSE ──<complex expression>─┴────────────────┤
An explanation of <try complex expression> is given in TRY Expression.
The imaginary part of a complex value can be equal to zero. Therefore, an arithmetic expression is, whenever necessary, considered to be the real part of a complex expression with a zero imaginary part. No automatic type conversion from complex to arithmetic exists.
The sequence in which the operations of a complex expression are performed is determined by the precedence of the operators involved. The order of precedence is as follows:
-
*, / (highest precedence)
-
+, --
Operators with the same precedence are applied in their order of appearance in an expression, from left to right.
The precedence of the assignment operator (:=) is as follows:
-
A primary to the right of an assignment operator is evaluated before the assignment.
-
The assignment is done before the evaluation of an expression involving the variable that is the target of the assignment.
For information on the order of evaluation of subscripts, see “Arithmetic Update Assignment” in Statements.
Parentheses can be used in normal mathematical fashion to override the defined order of precedence. An expression in parentheses is evaluated by itself, and the resulting value is subsequently combined with the other elements of the expression. In the following expression, for example, the addition is performed before the division because of the parentheses:
(C2 + C1)/C2
In the following expression, C1 is first divided by C2 and then the result is added to C2:
C2 + C1/C2
The evaluation of a conditional complex expression is described in Conditional Expressions.
The evaluation of a complex case expression is described in Case Expression.
Examples of Complex Expression
C1 C1+3 C1 ** X C1 := COMPLEX(X,Y) C1 := * - C2 CABS(C1) (COMPLEX(R,S) * CCON) CASE I OF (C1, C2, CLN(C2)) IF BOOL THEN C1 ELSE CONJUGATE(C1)

