Difference between revisions of "SHIP:Sail:Operators"

From Serious Documentation
Jump to: navigation, search
(See Also)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The following standard mathematical operators are available in Sail, listed in precedence order from first to last. Exceptions from C/Java are noted.
+
The following standard mathematical operators are available in Sail, listed in precedence order from first to last.  
  
 
{| class="wikitable" style="width:75%;margin: 1em auto 1em auto;"
 
{| class="wikitable" style="width:75%;margin: 1em auto 1em auto;"
Line 30: Line 30:
 
|-
 
|-
 
|align="center"|5
 
|align="center"|5
|align="center"|<nowiki>+</nowiki>&#160;&#160;<nowiki>-</nowiki>
+
|align="center"|<nowiki>+</nowiki><br><nowiki>-</nowiki>
|Addition, Subtraction
+
|{{†}}Addition<br>Subtraction
 
|-
 
|-
 
|align="center"|6
 
|align="center"|6
Line 39: Line 39:
 
|align="center"|7
 
|align="center"|7
 
|align="center"|&lt;&#160;&#160;&lt;<nowiki>=</nowiki><br>&gt;&#160;&#160;&gt;<nowiki>=</nowiki>
 
|align="center"|&lt;&#160;&#160;&lt;<nowiki>=</nowiki><br>&gt;&#160;&#160;&gt;<nowiki>=</nowiki>
|Less than, Less than or equal<br>Greater than, greater than or equal
+
|{{†}}Less than, {{†}}Less than or equal<br>{{†}}Greater than, {{†}}Greater than or equal
 
|-
 
|-
 
|align="center"|8
 
|align="center"|8
 
|align="center"|<nowiki>==</nowiki>&#160;&#160;<nowiki>!=</nowiki>
 
|align="center"|<nowiki>==</nowiki>&#160;&#160;<nowiki>!=</nowiki>
|Equal, not equal
+
|{{†}}Equal, {{†}}Not equal
 
|-
 
|-
 
|align="center"|9
 
|align="center"|9
Line 71: Line 71:
 
|-
 
|-
 
|align="center"|15
 
|align="center"|15
|align="center"|<nowiki>=</nowiki><br><nowiki>+=</nowiki>&#160;&#160;<nowiki>-=</nowiki><br><nowiki>*=</nowiki>&#160;&#160;<nowiki>/=</nowiki>&#160;&#160;<nowiki>%=</nowiki><br><nowiki><<=</nowiki>&#160;&#160;<nowiki>>>=</nowiki><br><nowiki>&=</nowiki>&#160;&#160;<nowiki>^=</nowiki>&#160;&#160;<nowiki>|=</nowiki>
+
|align="center"|<nowiki>=</nowiki><br><nowiki>+=</nowiki><br><nowiki>-=</nowiki><br><nowiki>*=</nowiki>&#160;&#160;<nowiki>/=</nowiki>&#160;&#160;<nowiki>%=</nowiki><br><nowiki><<=</nowiki>&#160;&#160;<nowiki>>>=</nowiki><br><nowiki>&=</nowiki>&#160;&#160;<nowiki>^=</nowiki>&#160;&#160;<nowiki>|=</nowiki>
|Assignment<br>Add- and Subtract-assign<br>Multiply-, Divide-, and Modulus-assign<br>Bitwise left, right shift-assign<br>Bitwise AND, XOR, OR assign
+
|{{†}}Assignment<br>{{†}}Add-assign<br>Subtract-assign<br>Multiply-, Divide-, and Modulus-assign<br>Bitwise left, right shift-assign<br>Bitwise AND, XOR, OR assign
 
|Right-to-Left
 
|Right-to-Left
 
|}
 
|}
 +
{{†}}These operators also can be used with the {{DataType|String}} data type.
 +
== See Also ==
 +
* [[SHIP:Data_Types|Data Types]]
 +
* [[SHIP:Node|Object Nodes, Properties, and Scope]]
 +
<!-- * [[SHIP:Sail:Operators|Operators]] -->
 +
* [[SHIP:Sail:Functions|Built-in Functions]]
 +
 +
[[Category:SHIPSail]]

Latest revision as of 17:11, 3 November 2016

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