# operators

Source: https://ref.dm-lang.org/operator/

Operators are used extensively in DM to compute numerical values.

The DM operators are:

<pre><a href="/operator/leftparenrightparen">()</a> <a href="/operator/path/dot">.</a> <a href="/operator/path/colon">:</a> <a href="/operator/path/slash">/</a> <a href="/operator/coloncolon">::</a>     <span class="DMc">// here . : / are path operators</span>
<a href="/operator/leftsquarerightsquare">[]</a> <a href="/operator/dot">.</a> <a href="/operator/colon">:</a>
<a href="/operator/queryleftsquarerightsquare">?[]</a> <a href="/operator/querydot">?.</a> <a href="/operator/querycolon">?:</a>
<a href="/operator/tilde">~</a> <a href="/operator/exclaim">!</a> <a href="/operator/minus">-</a> <a href="/operator/plusplus">++</a> <a href="/operator/minusminus">--</a> <a href="/operator/asterisk/pointer">*</a> <a href="/operator/amp/pointer">&</a>     <span class="DMc">// unary operators (* and & here are pointer operators)</span>
<a href="/operator/asteriskasterisk">**</a>
<a href="/operator/asterisk">*</a> <a href="/operator/slash">/</a> <a href="/operator/modulo">%</a> <a href="/operator/modulomodulo">&#37;&#37;</a>
<a href="/operator/plus">+</a> <a href="/operator/minus">-</a>
<a href="/operator/less"><</a> <a href="/operator/lessequals"><=</a> <a href="/operator/greater">></a> <a href="/operator/greaterequals">>=</a> <a href="/operator/lessequalsgreater"><=></a>
<a href="/operator/lessless"><<</a> <a href="/operator/greatergreater">>></a>
<a href="/operator/equalsequals">==</a> <a href="/operator/exclaimequals">!=</a> <a href="/operator/lessgreater"><></a> <a href="/operator/tildeequals">~=</a> <a href="/operator/tildeexclaim">~!</a>
<a href="/operator/amp">&</a>
<a href="/operator/caret">^</a>
<a href="/operator/vert">|</a>
<a href="/operator/ampamp">&&</a>
<a href="/operator/vertvert">||</a>
<a href="/operator/query">?</a>               <span class="DMc">// ternary a ? b : c</span>
<a href="/operator/equals">=</a> <a href="/operator/plusequals">+=</a> <a href="/operator/minusequals">-=</a> <a href="/operator/minusequals">-=</a> <a href="/operator/asteriskequals">*=</a> <a href="/operator/slashequals">/=</a> <a href="/operator/moduloequals">%=</a> <a href="/operator/modulomoduloequals">&#37;&#37;=</a> <a href="/operator/ampequals">&=</a> <a href="/operator/vertequals">|=</a> <a href="/operator/caretequals">^=</a> <a href="/operator/lesslessequals"><<=</a> <a href="/operator/greatergreaterequals">>>=</a> <a href="/operator/colonequals">:=</a> <a href="/operator/ampampequals">&&=</a> <a href="/operator/vertvertequals">||=</a>
<a href="/operator/in">in</a></pre>

Each line has higher order of operations than the next. Operators within a line have equal precedence and therefore are processed from left to right as they occur in an expression. (Assignment, or operate-and-assign, are processed from right to left.)

Expressions of the form `A #= B` are shorthand for `A = A # B` except for `~=` and `:=`.

```dm
var/N
N = 0                          // 0
N += 1+1*2                     // 3
if(1 + 1 == 2) N = 2           // 2
if(N==2 && 1/2==0.5) N = 0.5   // 0.5
```

### See also
> [operator overloading](https://ref.dm-lang.org/operator/overload.md)

## Pages

- [& operator](https://ref.dm-lang.org/operator/amp/index.md)
- [&& operator](https://ref.dm-lang.org/operator/ampamp.md)
- [&&= operator](https://ref.dm-lang.org/operator/ampampequals.md)
- [&= operator](https://ref.dm-lang.org/operator/ampequals.md)
- [* operator](https://ref.dm-lang.org/operator/asterisk/index.md)
- [** operator](https://ref.dm-lang.org/operator/asteriskasterisk.md)
- [*= operator](https://ref.dm-lang.org/operator/asteriskequals.md)
- [^ operator](https://ref.dm-lang.org/operator/caret.md)
- [^= operator](https://ref.dm-lang.org/operator/caretequals.md)
- [: operator](https://ref.dm-lang.org/operator/colon.md)
- [:: operator](https://ref.dm-lang.org/operator/coloncolon.md)
- [:= operator](https://ref.dm-lang.org/operator/colonequals.md)
- [. operator](https://ref.dm-lang.org/operator/dot.md)
- [= operator](https://ref.dm-lang.org/operator/equals.md)
- [== operator](https://ref.dm-lang.org/operator/equalsequals.md)
- [! operator](https://ref.dm-lang.org/operator/exclaim.md)
- [!= operator](https://ref.dm-lang.org/operator/exclaimequals.md)
- [> operator](https://ref.dm-lang.org/operator/greater.md)
- [>= operator](https://ref.dm-lang.org/operator/greaterequals.md)
- [>> operator](https://ref.dm-lang.org/operator/greatergreater/index.md)
- [>>= operator](https://ref.dm-lang.org/operator/greatergreaterequals.md)
- [in operator](https://ref.dm-lang.org/operator/in.md)
- [() operator](https://ref.dm-lang.org/operator/leftparenrightparen.md)
- [[] operator](https://ref.dm-lang.org/operator/leftsquarerightsquare.md)
- [< operator](https://ref.dm-lang.org/operator/less.md)
- [<= operator](https://ref.dm-lang.org/operator/lessequals.md)
- [<=> operator](https://ref.dm-lang.org/operator/lessequalsgreater.md)
- [<> operator](https://ref.dm-lang.org/operator/lessgreater.md)
- [<< operator](https://ref.dm-lang.org/operator/lessless/index.md)
- [<<= operator](https://ref.dm-lang.org/operator/lesslessequals.md)
- [- operator](https://ref.dm-lang.org/operator/minus.md)
- [-= operator](https://ref.dm-lang.org/operator/minusequals.md)
- [-- operator](https://ref.dm-lang.org/operator/minusminus.md)
- [% operator](https://ref.dm-lang.org/operator/modulo.md)
- [%= operator](https://ref.dm-lang.org/operator/moduloequals.md)
- [%% operator](https://ref.dm-lang.org/operator/modulomodulo.md)
- [%%= operator](https://ref.dm-lang.org/operator/modulomoduloequals.md)
- [operator overloading](https://ref.dm-lang.org/operator/overload.md)
- [path operators](https://ref.dm-lang.org/operator/path/index.md)
- [+ operator](https://ref.dm-lang.org/operator/plus.md)
- [+= operator](https://ref.dm-lang.org/operator/plusequals.md)
- [++ operator](https://ref.dm-lang.org/operator/plusplus.md)
- [? operator](https://ref.dm-lang.org/operator/query.md)
- [?: operator](https://ref.dm-lang.org/operator/querycolon.md)
- [?. operator](https://ref.dm-lang.org/operator/querydot.md)
- [?[] operator](https://ref.dm-lang.org/operator/queryleftsquarerightsquare.md)
- [/ operator](https://ref.dm-lang.org/operator/slash.md)
- [/= operator](https://ref.dm-lang.org/operator/slashequals.md)
- [~ operator](https://ref.dm-lang.org/operator/tilde.md)
- [~= operator](https://ref.dm-lang.org/operator/tildeequals.md)
- [~! operator](https://ref.dm-lang.org/operator/tildeexclaim.md)
- [| operator](https://ref.dm-lang.org/operator/vert.md)
- [|= operator](https://ref.dm-lang.org/operator/vertequals.md)
- [|| operator](https://ref.dm-lang.org/operator/vertvert.md)
- [||= operator](https://ref.dm-lang.org/operator/vertvertequals.md)
