When evaluating expressions in a programming language, it is important to understand the order of operations, also know as operator precedence. The following table describes Cubloc BASIC's operator precedence.
Operator | Explanation | Type | Precendence |
---|---|---|---|
^ | To the power of | Math | First |
*,/,MOD | Multiply, Divide, MOD | Math | |
+,- | Add, Subtract | Math | |
«, » | Left Shift, Right Shift | Logic | |
<, >, ⇐, >= | Less than, Larger than, Less or Equal to , Larger or Equal to. | Comparison | |
=, <> | Same, Different | Comparison | |
AND, XOR, OR,NOT | Boolean AND, XOR, OR, & NOT | Logic | Last |
Within each row in the table above, the operators are evaluated from left to right.
The And, Xor, and Or operators are used for both logical and bit-wise operations.
If A=1 And B=1 Then C=1 ' if A=1 and B=1 …(Logical Operation) If A=1 Or B=1 Then C=1 ' if A=1 or B=1…(Logical Operation) A = B And &HF 'Set the upper 4 bits to zero. (Bit-wise Operation) A = B Xor &HF 'Invert the lower 4 bits. (Bit-wise Operation) A = B Or &HF 'Set the lower 4 bits to 1. (Bit-wise Operation).
That's it. You just finish about CUBLOC BASIC.