Contents | Prev | Next | Index
+ | sum |
- | difference |
* | product |
/ | real quotient |
DIV | integer quotient |
MOD | modulus |
The operators +, -, and * apply to operands of numeric types or subranges thereof. Both operands must be either of an integer type, a cardinal type or a real type. The result type is the one that includes the types of the both operands.
The operator / applies to operands of real type, where the result is the smallest real type that includes both operand types.
When used as unary operators, - denotes sign inversion and + denotes the identity operation. A sign inversion applies to an integer or real operand only.
The operators DIV and MOD apply to operands which are either both of integer or both of cardinal types only. The result type is the one that includes the types of the both operands. They are related by the following formulas, defined for any x and positive divisor y:
x = (x DIV y) * y + (x MOD y)
0 <= (x MOD y) < y
When the language extensions are enabled via a compiler switch or directive, the following bitwise operators are also available:
AND | bitwise logical and |
& | bitwise logical and |
OR | bitwise logical or |
XOR | bitwise logical exclusive or |
NOT | bitwise negation (unary operator) |
~ | bitwise negation (unary operator) |
SHR | bitwise shift right |
SHL | bitwise shift left |
A bitwise logical operator applies to operands which are either both of integer type or both of cardinal type only. The result type is the one that includes the types of the both operands. The bitwise negation is a unary operator and only applies to an integer or cardinal operand.
Examples:
x | y | x DIV y | x MOD y |
5 | 3 | 1 | 2 |
-5 | 3 | -2 | 1 |
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