In this context, we’re talking about simple mathematical expressions like
5 + 5
. There are three ways to write these types of expressions:
+ 5 5
)5 + 5
)5 5 +
)The Expression Translator application allows you to enter an expression in any of the three formats, and will convert the expression to any of the three formats. It will also evaluate the expression and display the answer.
The interesting thing about this is that Infix can potentially require parentheses. Actually, it is the only form that ever uses them.
Take the expression (5 + 5) * 3
, for example. Because of the parentheses, you
would evaluate 5 + 5
first, and then multiply the result by 3
to get 30
.
Without the parentheses, multiplication has higher precedence than addition, so
you would evaluate 5 * 3
first, then add 5
to the result to get 20
.
(5 + 5) * 3
and 5 + 5 * 3
are extremely similar when represented in Infix.
The only difference is the parentheses. When written in Prefix or Postfix,
however, you must actually change the order of the characters in the expression
to change its meaning. For example:
(5 + 5) * 3
* + 5 5 3
Postfix:5 5 + 3 *
5 + 5 * 3
+ 5 * 5 3
5 5 3 * +
The binary is available here: Expression Translator Binary
The original source code is also available here: Expression Translator Source
Adam Platt is a technologist with more than a decade of experience across the full stack. His passion for technology and penchant for rendering complex technical ideas into simple terms have made him an in-demand speaker. His resume includes BriForum, the PowerShell Summit, teaching engagements and more.
He is one of the 10 types of people who understand binary and he can solve a Rubik’s Cube.
Adam Platt is a technologist with more than a decade of experience across the full stack. His passion for technology and penchant for rendering complex technical ideas into simple terms have made him an in-demand speaker. His resume includes BriForum, the PowerShell Summit, teaching engagements and more.
He is one of the 10 types of people who understand binary and he can solve a Rubik’s Cube.