Operator Precedence
- Everyone knows that multiply takes precedence over add, e.g., 3+5×3 = 18, not 24
- C-language precedence is too intricate for most programmers to use extensively
- TEX doesn't use precedence; relies on { } to define operator scope
- In general, ( ) can be used to clarify or overrule precedence
- Precedence reduces clutter, so some precedence is desirable (else things look like LISP!)
- But keep it simple enough to remember easily
Operands in subscripts, superscripts, fractions, roots, boxes, etc. are defined in part in terms of operators and operator precedence. While such notions are very familiar to mathematically oriented people, some of the symbols that we define as operators might surprise one at first. Most notably, the space (ASCII 32) is an important operator in the plain-text encoding of mathematics.
Layout Operator Precedence
| Subscript, superscript |
|
¯ |
| Integral, sum |
|
ò S P |
| Functions |
|
Ö |
| Times, divide |
|
/ * × • • |
| Other operators |
|
Space ". , = - + Tab |
| Right brackets |
|
)]}| |
| Left brackets |
|
([{ |
| End of paragraph |
|
FF EOP |
A minimal list of operators is given above, where FF = U+000C and an EOP can be given by a lone LF, a lone CR, or a CRLF, where LF = U+000A and CR = U+000D.
As in arithmetic, operators have precedence, which streamlines the interpretation of operands. The operators are grouped above in order of increasing precedence, with equal precedence values on the same line. For example, in arithmetic, 3 + 1/2 = 3.5, not 2.