SHIP:Sail:Operators

From Serious Documentation
Jump to: navigation, search

The following standard mathematical operators are available in Sail, listed in precedence order from first to last.

SHIPSail Operators and Precedence
Group Operator(s) Description Order
1 . Identifier qualification Left-to-right
2 ++  --
()
Post-increment/decrement
Function call
3 ++  --
+ -
!  ~
Pre-increment/decrement
Unary plus/minus
Logical/Bitwise NOT
Right-to-left
4 *  /  % Multiplication, Division, Modulus Left-to-Right
5 +
-
Addition
Subtraction
6 <<  >> Bitwise left, right shift
7 <  <=
>  >=
Less than, Less than or equal
Greater than, Greater than or equal
8 ==  != Equal, Not equal
9 & Bitwise AND
10 ^ Bitwise XOR
11 | Bitwise OR
12 && Logical AND
13 || Logical OR
14 :? Ternary Conditional Right-to-Left; Expression between ? and ? always parsed as if parenthesized.
15 =
+=
-=
*=  /=  %=
<<=  >>=
&=  ^=  |=
Assignment
Add-assign
Subtract-assign
Multiply-, Divide-, and Modulus-assign
Bitwise left, right shift-assign
Bitwise AND, XOR, OR assign
Right-to-Left

These operators also can be used with the String data type.

See Also