# Operators

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

The following operators are listed in order of precedence. Operators that are on the same level (for example +
and -) are processed with a left to right precedence as they occur on the program line.

Numeric Operators (Float or Integer)

NOT INV | NOT will invert the logical value on the right. INV will perform a bitwise inversion of the value on the right. Both of these have the highest precedence so if the value being operated on is an expression it should be surrounded by brackets. For example, IF NOT (A = 3 OR A = 8) THEN …
^ | Exponentiation (eg, b^n means b raised to the power n)
* / \ MOD | Multiplication, division, integer division and modulus (remainder)
+ - | Addition and subtraction
x << y x >> y | These operate in a special way. << means that the value returned will be the value of x shifted by y bits to the left while >> means the same only right shifted. They are integer functions and any bits shifted off are discarded. For a right shift any bits introduced are set to zero. For a left shift any bits introduced are set to zero.
x >>> y | For a right shift any bits introduced are set to the value of the top bit (bit 63). (CMM2 and Armite H7 only)
<> < > <= =< >= => | Inequality, less than, greater than, less than or equal to, less than or equal to (alternative version), greater than or equal to, greater than or equal to (alternative version)
= | Equality (also used in assignment to a variable, eg implied LET).
AND OR XOR | Conjunction, disjunction, exclusive or. These are bitwise operators and can be used on 64-bit unsigned integers.

The operators AND, OR and XOR are integer bitwise operators. For example PRINT (3 AND 6) will output 2.
The other logical operations result in the integer 0 (zero) for false and 1 for true.
For example the statement PRINT 4 >= 5 will print the number zero on the output and the expression A = 3 > 2 will store +1 in A.

String Operators

+ | Join two strings
<> < > <= =< >= => | Inequality, less than, greater than, less than or equal to, less than or equal to (alternative version), greater than or equal to, greater than or equal to (alternative version).
= | Equality

String comparisons respect the case of the characters (ie "A" is greater than "a").

The shift operators should only be used with Integers. Floats will give unreliable results.

DIM INTEGER x, y, z, w
x = 12345
y = x << 8
z = x >> 8
w = x >>> 8 ' not all versions have this operator
PRINT "x = ";BIN$(x,64);" ";x
PRINT "x << 8= ";BIN$(y,64);" ";y
PRINT
PRINT "x = ";BIN$(x,64);" ";x
PRINT "x >> 8= ";BIN$(z,64);" ";z
PRINT "x >>>8= ";BIN$(w,64);" ";w
PRINT
x = &h7FFFFFFFFFFF7F
y = x << 8
z = x >> 8
w = x >>> 8
PRINT "x = ";BIN$(x,64);" ";x
PRINT "x << 8= ";BIN$(y,64);" ";y
y = x << 9
PRINT "x << 9= ";BIN$(y,64);" ";y
PRINT
PRINT "x = ";BIN$(x,64);" ";x
PRINT "x >> 8= ";BIN$(z,64);" ";z
PRINT "x >>>8= ";BIN$(w,64);" ";w
PRINT
x = 0-&h7FFFFFFFFFFF7F
y = x << 8
z = x >> 8
w = x >>> 8
PRINT "x = ";BIN$(x,64);" ";x
PRINT "x << 8= ";BIN$(y,64);" ";y
y = x << 9
PRINT "x << 9= ";BIN$(y,64);" ";y
PRINT
PRINT "x = ";BIN$(x,64);" ";x
PRINT "x >> 8= ";BIN$(z,64);" ";z
PRINT "x >>>8= ";BIN$(w,64);" ";w
PRINT
Output:
x = 0000000000000000000000000000000000000000000000000011000000111001 12345
x << 8= 0000000000000000000000000000000000000000001100000011100100000000 3160320
x = 0000000000000000000000000000000000000000000000000011000000111001 12345
x >> 8= 0000000000000000000000000000000000000000000000000000000000110000 48
x >>>8= 0000000000000000000000000000000000000000000000000000000000110000 48
x = 0000000001111111111111111111111111111111111111111111111101111111 36028797018963839
x << 8= 0111111111111111111111111111111111111111111111110111111100000000 9223372036854742784
x << 9= 1111111111111111111111111111111111111111111111101111111000000000 -66048
x = 0000000001111111111111111111111111111111111111111111111101111111 36028797018963839
x >> 8= 0000000000000000011111111111111111111111111111111111111111111111 140737488355327
x >>>8= 0000000000000000011111111111111111111111111111111111111111111111 140737488355327
x = 1111111110000000000000000000000000000000000000000000000010000001 -36028797018963839
x << 8= 1000000000000000000000000000000000000000000000001000000100000000 -9223372036854742784
x << 9= 0000000000000000000000000000000000000000000000010000001000000000 66048
x = 1111111110000000000000000000000000000000000000000000000010000001 -36028797018963839
x >> 8= 0000000011111111100000000000000000000000000000000000000000000000 71916856549572608
x >>>8= 1111111111111111100000000000000000000000000000000000000000000000 -140737488355328

Last edited: 16 May, 2021