Common operator notation: Difference between revisions

Content deleted Content added
fixed date
improved ref
Line 6:
Operands are objects upon which the operators operate. These include literal [[number]]s and other constants as well as identifiers (names) which may represent anything from simple scalar variables to complex aggregated structures and objects, depending on the complexity and capability of the language at hand as well as usage context. One special type of operand is the parenthesis group. An expression enclosed in parentheses is typically recursively evaluated to be treated as a single operand on the next evaluation level.
 
Each operator is given a position, precedence, and an associativity. The '''operator precedence''' is a number (from high to low or vice versa) that defines which operator that takes an operand surrounded by two operators of different precedence (or priority). Multiplication normally has higher precedence than addition,<ref name="Bronstein_1987">{{cite book |title=Taschenbuch der Mathematik |title-link=:de:TaschenbuchBronstein derand MathematikSemendjajew |author-first1=Ilja Nikolaevič<!-- Nikolajewitsch --> |author-last1=Bronstein<!-- 1903–1976 --> |author-first2=Konstantin Adolfovič<!-- Adolfowitsch --> |author-last2=Semendjajew<!-- 1908–1988 --> |editor-first1=Günter |editor-last1=Grosche |editor-first2=Viktor |editor-last2=Ziegler<!-- 1922–1980--> |editor-first3=Dorothea |editor-last3=Ziegler |others=Weiß, Jürgen<!-- lector --> |translator-first=Viktor |translator-last=Ziegler |volume=1 |date=1987 |edition=23 |orig-year=1945 |publisher=[[:de:Verlag Harri Deutsch|Verlag Harri Deutsch]] (and [[B. G. Teubner Verlagsgesellschaft]], Leipzig) |___location=Thun and Frankfurt am Main |language=German |chapter=2.4.1.1. |pages=115-120 |isbn=3-87144-492-8}}</ref> for example, so 3+4×5 = 3+(4×5) ≠ (3+4)×5.
 
In terms of operator position, an operator may be prefix, postfix, or infix. A [[prefix operator]] immediately precedes its operand, as in −x. A [[postfix operator]] immediately succeeds its operand, as in x! for instance. An [[infix operator]] is positioned in between a left and a right operand, as in x+y. Some languages, most notably the C-syntax family, stretches this conventional terminology and speaks also of ''[[ternary operator|ternary]]'' infix operators (a?b:c). Theoretically it would even be possible (but not necessarily practical) to define parenthesization as a unary bifix operation.