Order of Precedence: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Add Columns template usage) |
Lou Montana (talk | contribs) m (Text replacement - "<tt>([a-zA-Z0-9\. _"\\']+)<\/tt>" to "{{hl|$1}}") |
||
Line 18: | Line 18: | ||
| | | | ||
Nular operators (commands with no arguments): | Nular operators (commands with no arguments): | ||
* | * {{hl|commandName}} | ||
| | | | ||
* [[Variables]] | * [[Variables]] | ||
Line 27: | Line 27: | ||
| | | | ||
Unary operators (commands with 1 argument): | Unary operators (commands with 1 argument): | ||
* | * {{hl|commandName}} a | ||
| {{Columns|2| | | {{Columns|2| | ||
* [[+ |+a]] | * [[+ |+a]] | ||
Line 84: | Line 84: | ||
| | | | ||
Binary operators (commands with 2 arguments): | Binary operators (commands with 2 arguments): | ||
* a | * a {{hl|commandName}} b | ||
| | | | ||
* [[setDir]] | * [[setDir]] |
Revision as of 23:54, 15 November 2021
Introduction
Order of operations, also called operator precedence, is a set of rules specifying which procedures should be performed first in a mathematical expression.
Precedence Overview
Precedence | Type of Operator | Examples |
---|---|---|
11 |
Nular operators (commands with no arguments):
|
|
10 |
Unary operators (commands with 1 argument):
|
|
9 | Hash-select operator | |
8 | Power operator | |
7 | ||
6 | ||
5 | N/A | |
4 |
Binary operators (commands with 2 arguments):
|
|
3 | ||
2 | Logical and operator | |
1 | Logical or operator |
Examples
Input | Process | Comment |
---|---|---|
1 + 2 * 3 |
1 + (2 * 3) |
result equals 7, and not 9 (see also PEMDAS) |
sleep 10 + random 20 |
(sleep 10) + random 20 |
sleep 10 will return Nothing, then + random 20 will be calculated but not used. |