Contents | Prev | Next | Index
For a given operator, the types of its operands are expression compatible if they conform to the following table (which also shows the result type of the expression).
Type T1 must be an extension of type T0. The type integer stands for SHORTINT, INTEGER, LONGINT or subranges thereof. The type cardinal stands for SHORTCARD, CARDINAL, LONGCARD or subranges thereof. The type real stands for SHORTREAL, REAL, or LONGREAL. The type char stands for CHAR or subranges thereof. The type Tb stands for a set base type of set type T. Some operators and operand types only apply when the language extensions are enabled via a compiler switch or directive. They are shown here in red color.
Operator | 1st Operand | 2nd Operand | Result Type |
+ - * | integer | integer | smallest integer type including both operand types |
+ - * | cardinal | cardinal | smallest cardinal type including both operand types |
+ - * | real | real | smallest real type including both operand types |
/ | real | real | smallest real type including both operand types |
DIV MOD | integer | integer | smallest integer type including both operand types |
DIV MOD | cardinal | cardinal | smallest cardinal type including both operand types |
+ - * / | set type T | set type T | set type T |
NOT ~ | BOOLEAN | BOOLEAN | |
OR AND & | BOOLEAN | BOOLEAN | BOOLEAN |
XOR | BOOLEAN | BOOLEAN | BOOLEAN |
OR AND & XOR SHL SHR | integer | integer | smallest integer type including both operand types |
cardinal | cardinal | smallest cardinal type including both operand types | |
= # <> < <= > >= | integer | integer | BOOLEAN |
cardinal | cardinal | BOOLEAN | |
char | char | BOOLEAN | |
real | real | BOOLEAN | |
BOOLEAN | BOOLEAN | BOOLEAN | |
enumeration type T | enumeration type T | BOOLEAN | |
= # <> | set type T | set type T | BOOLEAN |
NIL, pointer type T0 or T1 | NIL, pointer type T0 or T1 | BOOLEAN | |
NIL, procedure type T | NIL, procedure type T | BOOLEAN | |
IN | set base type Tb | set type T | BOOLEAN |
IS | type T0 | type T1 | BOOLEAN |
Contents | Prev | Next | Index
Canterbury Modula-2 for Java (Last documentation update
Feb 8, 2000)
Copyright © 1998 Mill Hill &
Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to
mhc@webcom.com