next up previous contents index
Next: Operator Overloading Up: The Xic Scripting Language Previous: Lexpers   Contents   Index


Math Operators

The following mathematical operations are supported:

Symbol Arity Description
+ binary addition
- unary negation
- binary subtraction
+ + unary pre- and post-increment
- - unary pre- and post-decrement
* binary multiplication
/ binary division
% binary remainder, e.g., 5%3 = 2
^ binary power, x ^ y = x to power y
& , and binary and, value is 1 if both operands are nonzero
| , or binary or, value is 1 if either operand is nonzero
! , ~ , not unary not, value is 1/0 if operand is zero/nonzero
> , gt binary greater than, value is 1 if left operand is greater than the right
> = , ge binary greater or equal, value is 1 if left operand is greater or equal to the right
< , lt binary less than, value is 1 if the left operand is less than the right
< = , le binary less or equal, value is 1 if the left operand is less than or equal to the right
! = , ne , < > , > < binary not equal, value is 1 if the left operand is not equal to the right
= = , eq binary equal, value is 1 if the left operand is equal to the right
= binary the left operand takes the value of the right, and the value is that of the right operand. The type of the left operand becomes that of the right.

A variable type is determined by its first assignment, of by declaration for arrays. It is generally an error to attempt to redefine a variable to a different type, though if a scalar is assigned from a handle, the scalar type is promoted to handle type.

Note that all operators, including assignment, return a value. Thus, expressions like 3*(x > y) make sense (the value is 0 or 3). Binary truth is indicated by a nonzero value.

The increment/decrement operators (++/-) behave as in the C language. That is

y = x + + is equivalent to y = x;x = x + 1
y = x - - is equivalent to y = x;x = x - 1
y = + + x is equivalent to x = x + 1;y = x
y = x - - is equivalent to x = x - 1;y = x



Subsections
next up previous contents index
Next: Operator Overloading Up: The Xic Scripting Language Previous: Lexpers   Contents   Index
Stephen R. Whiteley 2012-04-01