1.2.4. Operators

The supported operators are listed in Table 1.1:

Table 1.1. MxScript operators

CategoryOperatorsRestrictions
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 See Expressions.
Pointers

unary * &

Not supported in MxScript.
Structures. ->Not supported in MxScript.

The precedence and associativity of operators in MxScript is the same as for C. See Table 1.2:

Table 1.2. Associativity in expressions

OperatorsAssociativity
( )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

Copyright © 2007-2011 ARM. All rights reserved.ARM DUI 0371J
Non-ConfidentialID051712