-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the AbMath wiki!
There are three distinct types of mathematical notation: infix, prefix, and postfix (aka Reverse Polish Notation).
Type | Notation |
---|---|
Infix | 2 + 2 |
Prefix | + 2 2 |
Postfix | 2 2 + |
Infix notation has a major flaw when you are looking to create a calculator, order of operations and parentheses. When you write an equation such as (3 + 2) * 3
the computer has to recognize the fact any data inside the parentheses must be evaluated before the rest of the expression. In this specific example order of operations dictates that we add 3
and 2
before we multiply by 3
.
This can be a very error prone and tedious task and this is where postfix or prefix help us. In postfix and prefix the data given to us has already been converted into a format that we do not have to worry about order of operations and parentheses. Let us look at our example below.
Type | Notation |
---|---|
Infix | (3 + 2) * 3 |
Prefix | * + 3 2 3 |
Postfix | 3 2 + 3 * |
... Wikipedia Article on Infix
... Wikipedia Article on Prefix
... Wikipedia Article on Postfix
... Wikipedia Article on Shunting Yard Algorithm