Difference between revisions of "MC-Basic Operators"
m (→String concatenations: moved to Language basics) |
(added to Category:Control:Offline) |
||
Line 143: | Line 143: | ||
[[Category:Axystems:MC-Basic]] | [[Category:Axystems:MC-Basic]] | ||
+ | [[Category:Control:Offline]] |
Revision as of 15:59, 19 January 2011
The tables shown below list the different types of operators, and their relative precedence. Arithmetic operators have the highest precedence, followed by Relational, Logical and Bit-wise operators. The relative precedence of the operators within each group is noted in the tables. Parentheses may be used to force a different order of expression processing because parentheses have the highest precedence. The “+” operator can be used to concatenate strings, and the “=” operator can be used to copy strings. The other operators have no applicability with strings.
The “=” operator can also be utilized to copy the entire values of an array to another array (matching in size and number of dimensions) through a single assignment statement. Other operators have no applicability with whole arrays.
Arithmetic Operators
Operation | Symbol | Relative Precedence |
---|---|---|
Exponentiation | ^ | 1 |
Negation/N/A minus | - | 2 |
Multiplication | * | 3 |
Division | / | 3 |
Modulus | MOD | 4 |
Addition | + | 5 |
Subtraction | - | 5 |
Relational Operators
Relational operators provide a method whereby two values may be compared. The result of the comparison is either TRUE (1) or FALSE (0). The operators are listed below; all Relational Operators have the same level of precedence, and relational operators have lower precedence than arithmetic operators. Relational operators may be used with any type of variable or value, including strings. String comparisons are made character-by-character, starting with the first character in each string, thus the string “de” is greater than the string “abc”. Character comparisons are made according to the value of the ASCII character codes for the respective characters.
Operation | Symbol | Relative Precedence |
---|---|---|
Equality | = | 1 |
Inequality | <> | 1 |
Less than | < | 1 |
Greater than | > | 1 |
Less than or equal to | <= | 1 |
Greater than or equal to | >= | 1 |
Logical Operators
Logical operators perform tests on multiple relations, and return a True (nonzero) or False (zero) value to be used in making a decision. Logical operators have lower precedence than Relational operators. They may be used on integer operands only (including the results of relational expressions).
Operation | Symbol | Relative Precedence |
---|---|---|
Complement | NOT | 1 |
And | AND | 2 |
Or | OR | 3 |
Exclusive Or | XOR | 4 |
Bit-wise Operators
Bitwise operators perform bit manipulations on integer operands only. The result of the operation is a Long.
Operation | Symbol | Relative Precedence |
---|---|---|
Bitwise complement | BNOT | 1 |
Bitwise And | BAND | 2 |
Bitwise Or | BOR | 3 |
Bitwise Exclusive Or | BXOR | 4 |