Polish notation, invented by Jan Łukasiewicz, writes operators before their operands, so no brackets are needed. Reverse Polish notation (operators after operands) is used by HP calculators, the Forth and PostScript languages and inside compilers.
How to use the Polish Notation Converter
- Conversion
- Expression
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Infix expressions are converted with Dijkstra’s shunting-yard algorithm, respecting precedence (^ before × ÷ before + −) and right-associative powers. Prefix and postfix inputs are parsed into an expression tree and printed back with the minimum brackets.
Formula
Infix (A + B) × C ↔ Prefix × + A B C ↔ Postfix A B + C ×
Worked example
Inputs — Conversion: Infix → postfix; Expression: (3 + 4) * 2 - 10 / 5.
Results — Result = 3 4 + 2 * 10 5 / -; Prefix (Polish) = - * + 3 4 2 / 10 5; Postfix (reverse Polish) = 3 4 + 2 * 10 5 / -; Infix = (3 + 4) * 2 - 10 / 5; Value = 12.
Key terms
- Infix
- Operators between operands, as usually written.
- Shunting-yard algorithm
- Dijkstra's method for converting infix to postfix.
Frequently asked questions
What is reverse Polish notation?
Postfix notation: operators follow their operands, e.g. 3 4 + for 3 + 4.
Why are brackets not needed?
The order of operators and operands fixes the order of evaluation.
Which operators are supported?
+ − * / and ^, with letters or numbers as operands.
How do I separate tokens in prefix input?
With spaces, e.g. "- * + 3 4 2 / 10 5".