Order of Precedence: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "== Introduction == Order of operations, also called operator precedence, is a set of rules specifying which procedures should be performed first in a mathematical expression....")
 
m (table formatting and onlyInclude tag)
Line 2: Line 2:
Order of operations, also called operator precedence, is a set of rules specifying which procedures should be performed first in a mathematical expression.
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 ==
<onlyinclude>
{{Feature | Informative |
{{Feature | Informative |
* Highest precedence means highest priority
* Highest precedence means highest priority
Line 27: Line 29:
* <tt>commandName</tt> a
* <tt>commandName</tt> a
|
|
<div style="columns: 2">
* [[+ |+a]]
* [[+ |+a]]
* [[- | -a]]
* [[- | -a]]
* [[+ | +array]]
* [[+ | +array]]
* [[!_a | !b]]
* [[!_a | !b]]
* [[not | not b]]
* [[not | not b]]
</div>
|-
|-
| style="text-align: center" | 9
| style="text-align: center" | 9
Line 51: Line 53:
* [[Config]] access ([[config / name|/]])
* [[Config]] access ([[config / name|/]])
|
|
<div style="columns: 2">
* [[a * b]]
* [[a * b]]
* [[a / b]]
* [[a / b]]
* [[a % b]]
* [[a % b]]
* [[mod | a mod b]]
* [[mod | a mod b]]
* [[config / name]]
* [[config / name]]
* [[atan2| a atan2 b]]
* [[atan2| a atan2 b]]
</div>
|-
|-
| style="text-align: center" | 6
| style="text-align: center" | 6
Line 67: Line 69:
* [[min]] and [[max]] commands
* [[min]] and [[max]] commands
|
|
<div style="columns: 2">
* [[+ | a + b]]
* [[+ | a + b]]
* [[- | a - b]]
* [[- | a - b]]
* [[+ | arr1 + arr2]]
* [[+ | arr1 + arr2]]
* [[- | arr1 - arr2]]
* [[- | arr1 - arr2]]
* [[+ | str1 + str2]]
* [[+ | str1 + str2]]
* [[min | a min b]]
* [[min | a min b]]
* [[max | a max b]]
* [[max | a max b]]
</div>
|-
|-
| style="text-align: center" | 5
| style="text-align: center" | 5
Line 97: Line 98:
* [[Config]] access ([[config greater greater name|&gt;&gt;]])
* [[Config]] access ([[config greater greater name|&gt;&gt;]])
|
|
<div style="columns: 2">
* [[a == b]]
* [[a == b]]
* [[a != b]]
* [[a != b]]
Line 103: Line 105:
* [[a_less=_b| a &gt;= b]]
* [[a_less=_b| a &gt;= b]]
* [[a_less=_b| a &lt;= b]]
* [[a_less=_b| a &lt;= b]]
 
</div>
* [[config_greater_greater_name | config >> name]]
* [[config_greater_greater_name | config >> name]]
|-
|-
Line 118: Line 120:
* [[or]]
* [[or]]
|}
|}
 
</onlyinclude>
[[Category:Scripting Topics]]
[[Category:Scripting Topics]]

Revision as of 18:52, 10 February 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

  • Highest precedence means highest priority
  • Associativity is (then) done from left to right, for example 3 + 5 + 8 will be processed as ((3 + 5) + 8)
Precedence Type of Operator Examples
11

Nular operators (commands with no arguments):

  • commandName
10

Unary operators (commands with 1 argument):

  • commandName a
9 Hash-select operator
8 Power operator
7
6
5 N/A
4

Binary operators (commands with 2 arguments):

  • a commandName b
3
2 Logical and operator
1 Logical or operator