4.6.2 Infix Operators
Infix operators are binary operators and operate on two operands, one on
either side. Operators have a precedence, by type, as shown in the table below; but,
operations with equal precedence are performed left to right as they appear in the source.
Apart from with the +
or –
operators, both operands must
be absolute, and the result is absolute.
Operator | Description | Example |
---|---|---|
Arithmetic Operators | ||
* |
Multiplication | 5 * 4 (=20) |
/ |
Division. Truncation is the same as the C operator ‘/’. | 23 / 4 (=5) |
% |
Remainder | 30 % 4 (=2) |
<< |
Shift Left. Same as the C operator ‘<<’ | 2 << 1 (=4) |
>> |
Shift Right. Same as the C operator ‘>>’ | 2 >> 1 (=1) |
Bitwise Operators | ||
& |
Bit-wise And | 4 & 6 (=4) |
^ |
Bit-wise Exclusive Or | 4 ^ 6 (=2) |
! |
Bit-wise Or Not | 0x1010 ! 0x5050
(=0xBFBF) |
| |
Bit-wise Inclusive Or | 2 | 4 (=6) |
Simple Arithmetic Operators | ||
+ |
Addition. If either argument is absolute, the result has the section of the other argument. You may not add together arguments from different sections. | 4 + 10 (=14) |
- |
Subtraction. If the right argument is absolute, the result has the section of the left argument. If both arguments are in the same section, the result is absolute. You may not subtract arguments from different sections. | 14 - 4 (=10) |
Relational Operators | ||
== |
Equal to | .if (x == y) |
!= |
Not equal to (also <> ) |
.if (x != y) |
< |
Less than | .if (x < 5) |
<= |
Less than or equal to | .if (y <= 0) |
> |
Greater than | .if (x > a) |
>= |
Greater than or equal to | .if (x >= b) |
Logical Operators | ||
&& |
Logical AND | .if ((x > 1) && (x <
10)) |
|| |
Logical OR | .if ((y != x) || (y <
100)) |