Infix notation
Encyclopedia
Infix notation is the common arithmetic and logical formula notation, in which operators are written infix
Infix
An infix is an affix inserted inside a word stem . It contrasts with adfix, a rare term for an affix attached to the end of a stem, such as a prefix or suffix.-Indonesian:...

-style between the operand
Operand
In mathematics, an operand is the object of a mathematical operation, a quantity on which an operation is performed.-Example :The following arithmetic expression shows an example of operators and operands:3 + 6 = 9\;...

s they act on (e.g. 2 + 2). It is not as simple to parse
Parsing
In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a text, made of a sequence of tokens , to determine its grammatical structure with respect to a given formal grammar...

 by computers as prefix notation
Polish notation
Polish notation, also known as prefix notation, is a form of notation for logic, arithmetic, and algebra. Its distinguishing feature is that it places operators to the left of their operands. If the arity of the operators is fixed, the result is a syntax lacking parentheses or other brackets that...

 ( e.g. + 2 2 ) or postfix notation
Reverse Polish notation
Reverse Polish notation is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position. It is also known as Postfix notation and is parenthesis-free as long as operator arities are fixed...

 ( e.g. 2 2 + ), but many programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

s use it due to its familiarity.

In infix notation, unlike in prefix or postfix notations, parentheses surrounding groups of operands and operators are necessary to indicate the intended order in which operations are to be performed. In the absence of parentheses, certain precedence rules determine the order of operations
Order of operations
In mathematics and computer programming, the order of operations is a rule used to clarify unambiguously which procedures should be performed first in a given mathematical expression....

.

Infix notation may also be distinguished from function
Function (mathematics)
In mathematics, a function associates one quantity, the argument of the function, also known as the input, with another quantity, the value of the function, also known as the output. A function assigns exactly one output to each input. The argument and the value may be real numbers, but they can...

 notation, where the name of a function suggests a particular operation, and its arguments are the addends. An example of such a function notation would be S(1,3) in which the function S denotes addition: S(1,3) = 1+3 = 4.

Examples of Infix Notation

(1 × 23) - 3 + 4 × 5 would be evaluated as:
(1 × 2 ^ 3) - 3 + 4 × 5
= (1 × 8) - 3 + 4 × 5
= 8 - 3 + 4 × 5
= 8 - 3 + 20
= 5 + 20
= 25

See also

  • Calculator input methods
    Calculator input methods
    There are various ways in which a calculator might interpret key strokes.One can categorize calculators into two main types: 1) single-step or immediate execution calculators and 2) expression or formula calculators....

    : comparison of notations as used by pocket calculators
  • postfix notation, also called Reverse Polish notation
    Reverse Polish notation
    Reverse Polish notation is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position. It is also known as Postfix notation and is parenthesis-free as long as operator arities are fixed...

  • prefix notation, also called Polish notation
    Polish notation
    Polish notation, also known as prefix notation, is a form of notation for logic, arithmetic, and algebra. Its distinguishing feature is that it places operators to the left of their operands. If the arity of the operators is fixed, the result is a syntax lacking parentheses or other brackets that...

  • Shunting yard algorithm
    Shunting yard algorithm
    The shunting-yard algorithm is a method for parsing mathematical expressions specified in infix notation. It can be used to produce output in Reverse Polish notation or as an abstract syntax tree...

    , used to convert infix notation to postfix notation or to a tree
  • Operator (programming)
    Operator (programming)
    Programming languages typically support a set of operators: operations which differ from the language's functions in calling syntax and/or argument passing mode. Common examples that differ by syntax are mathematical arithmetic operations, e.g...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK