and then
and or else
have the same precedence as logical operators. The membership tests in
and not in
have the same precedence as relational operators.
abs
and not
. The effect of the predefined operators is explained in subsections 4.5.1 through 4.5.7.
and then
and or else
are defined for two operands of a boolean type and deliver a result of the same type. The left operand of a short-circuit control form is always evaluated first. If the left operand of an expression with the control form and then
evaluates to FALSE, the right operand is not evaluated and the value of the expression is FALSE. If the left operand of an expression with the control form or else
evaluates to TRUE, the right operand is not evaluated and the value of the expression is TRUE. If both operands are evaluated, and then
delivers the same result as and
, and or else
delivers the same result as or
.
6
| A | B |
A and B
|
A or B
|
A xor B
|
---|---|---|---|---|---|
| TRUE | TRUE | TRUE | TRUE | FALSE |
| TRUE | FALSE | FALSE | TRUE | TRUE |
| FALSE | TRUE | FALSE | TRUE | TRUE |
| FALSE | FALSE | FALSE | FALSE | FALSE |
SUNNY or
WARM
FILTER(1 .. 10) and FILTER(15 .. 24) -- see
3.6.1
NEXT_CAR.OWNER /= null and then
NEXT_CAR.OWNER.AGE > 25
-- see 3.8.1
N = 0 or else
A(N) = HIT_VALUE
3 | Operator | Operation | Operand type | Result type |
---|---|---|---|---|
| = /= | equality and inequality | any type | BOOLEAN |
| < <= > >= | test for ordering |
any scalar type discrete array type |
BOOLEAN BOOLEAN |
in
and not in
are predefined for all types. The result type is the predefined type BOOLEAN. For a membership test with a range, the simple expression and the bounds of the range must be of the same scalar type; for a membership test with a type mark, the type of the simple expression must be the base type of the type mark. The evaluation of the membership test in
yields the result TRUE if the value of the simple expression is within the given range, or if this value belongs to the subtype denoted by the given type mark; otherwise this evaluation yields the result FALSE (for a value of a real type, see 4.5.7). The membership test not in
gives the complementary result to the membership test in
.
Z + 0.1 -- Z must be of a real type
`A' & "BCD" -- catenation of a character literal and a string
literal
`A' & `A' -- catenation of two character literals
2
| Operator | Operation | Operand type | Result type |
---|---|---|---|---|
|
+
| identity | any numeric type | same numeric type |
|
-
| negation | any numeric type | same numeric type |
mod
and rem
are predefined for any integer type. For each of these operators, the operands and the result have the same base type. For floating point types, the accuracy of the result is determined by the operand type (see 4.5.7).
A = (A/B)*B + (A
rem
B)
rem
B) has the sign of A and an absolute value less than the absolute value of B. Integer division satisfies the identity
(-A)/B = -(A/B) = A/(-B)
mod
B) has the sign of B and an absolute value less than the absolute value of B; in addition, for some integer value N, this result must satisfy the relation
A = B*N + (A
mod
B)
rem
, and mod
if the right operand is zero.
I : INTEGER := 1;
J : INTEGER := 2;
K : INTEGER := 3;
digits
6 := 1.0; -- see 3.5.7
Y : REAL digits
6 := 2.0;
F : FRACTION delta
0.0001 := 0.1; -- see 3.5.9
G : FRACTION delta
0.0001 := 0.1;
Expression | Value | Result Type |
---|---|---|
I*J
|
2
|
same as I and J, that is, INTEGER
|
K/J
|
1
|
same as K and J, that is, INTEGER
|
K mod J
|
1
|
same as K and J, that is, INTEGER
|
X/Y
|
0.5
|
same as X and Y, that is, REAL
|
F/2
|
0.05
|
same as F, that is, FRACTION
|
rem
B is the remainder when A is divided by B. The following relations are satisfied by the rem
operator:
A
rem
(-B) = A rem
B
(-A) rem
B = -(A rem
B)
A
mod
B = (A + K*B) mod
B
A
B
A/B
A rem
B
A mod
B
A
B
A/B
A rem
B
A mod
B
10
5
2
0
0
-10
5
-2
0
0
11
5
2
1
1
-11
5
-2
-1
4
12
5
2
2
2
-12
5
-2
-2
3
13
5
2
3
3
-13
5
-2
-3
2
14
5
2
4
4
-14
5
-2
-4
1
10
-5
-2
0
0
-10
-5
2
0
0
11
-5
-2
1
-4
-11
-5
2
-1
-1
12
-5
-2
2
-3
-12
-5
2
-2
-2
13
-5
-2
3
-2
-13
-5
2
-3
-3
14
-5
-2
4
-1
-14
-5
2
-4
-4
abs
is predefined for any numeric type. The highest precedence unary operator not
is predefined for any boolean type and any one-dimensional array type whose components have a boolean type.
2
| Operator | Operation | Operand type | Result type |
---|---|---|---|---|
|
abs
| absolute value | any numeric type | same integer type |
|
not
| logical negation |
any boolean type array of boolean components |
same boolean type same array type |
not
that applies to a one-dimensional array of boolean components yields a one-dimensional boolean array with the same bounds; each component of the result is obtained by logical negation of the corresponding component of the operand (that is, the component that has the same index value).
5
| Operator | Operation | Left operand type | Right operand type | Result type |
---|---|---|---|---|---|
|
**
| exponentiation |
any integer type any floating point type V |
INTEGER INTEGER |
same as left same as left |