Script arithmetic operators and functions
You can use a variety of arithmetic operators and functions in dynamic variable expressions. To override the default precedence of operators, use parentheses. Operators include:
Operator | Name | Syntax |
---|---|---|
(, ) | Parentheses | (x) |
[, ] | Matrix, Index | […] |
, | Parameter separator | x, y |
; | Statement separator | x; y |
; | Row separator | [x, y] |
\n | Statement separator | x \n y |
+ | Add | x + y |
+ | Unary plus | +y |
– | Subtract | x – y |
– | Unary minus | -y |
* | Multiply | x * y |
.* | Element-wise multiply | x .* y |
/ | Divide | x / y |
./ | Element-wise divide | x ./ y |
%, mod | Modulus | x % y |
^ | Power | x ^ y |
.^ | Element-wise power | x .^ y |
‘ | Transpose | y’ |
! | Factorial | y! |
& | Bitwise and | x & y |
~ | Bitwise not | ~x |
| | Bitwise or | x | y |
^| | Bitwise xor | x ^| y |
<< | Left shift | x << y |
>> | Right arithmetic shift | x >> y |
>>> | Right logical shift | x >>> y |
and | Logical and | x and y |
not | Logical not | not y |
or | Logical or | x or y |
xor | Logical xor | x xor y |
= | Assignment | x = y |
? : | Conditional expression | x ? y : z |
: | Range | x : y |
to, in | Unit conversion | x to y |
== | Equal | x == y |
!= | Unequal | x != y |
< | Smaller | x < y |
> | Larger | x > y |
<= | Smallereq | x<= y |
>= | Largereq | x >= y |