1.2.4 Operators

The supported operators are listed in a table.

Table 1-1 MxScript operators

Category Operators Restrictions
Assignment
=
Works on all types and returns the same type.
Arithmetical
+ - * %
++ --
+= -= *= /= %=
Work on all number types (int and double) and the result of same type, except that the increment operators ++ and -- can only be used with int values.
String
+ = += *=
Use to concatenate strings, assign to string, or append to string. The *= form is used to concatenate multiple copies of a string back to the original string as in my_string_var *= 3.
Relationship
== !=
< > <= >=
Works on all types, including strings. Result is bool.
The <, >, <=, and >= cannot be used with bool types.
Logical
&& || !
Works on bool types. Result is bool.
Bitwise
& | ^ ~ << >>
&= |= ^= <<= >>=
Works on int. Result is int.
Shift operators are, unlike in C, well defined for shifts larger than the size of the integer type (64 bits).
Casting
type(exp)
(type) exp
Both C and C++ forms of casts are supported in MxScript.
Pointers
Unary * &
Not supported in MxScript.
Structures . -> Not supported in MxScript.
The precedence and associativity of operators in MxScript are the same as for C.

Table 1-2 Associativity in expressions

Operators Associativity
( ) Left to right.
Unary operators: !, ~, ++, --, +, -, (type), type( )
Right to left.
* / % Left to right.
+ - Left to right.
<< >> Left to right.
< <= > >= Left to right.
== != Left to right.
& Left to right.
^ Left to right.
| Left to right.
&& Left to right.
|| Left to right.
?: Right to left.
= += -= *= /= %= &= ^= |= <<= >>= Right to left.
, Left to right.
Related reference
1.2.7 Expressions
Non-ConfidentialPDF file icon PDF versionARM DUI0371M
Copyright © 2007-2014 ARM. All rights reserved.