Reverse Polish Notation is a way of expressing arithmetic expressions that avoids the use of brackets to define priorities for evaluation of operators. In ordinary notation, one might write
(3 + 5) * (7 - 2)
and the brackets tell us that we have to add 3 to 5, then subtract 2 from 7, and multiply the two results together. In RPN, the numbers and operators are listed one after another, and an operator always acts on the most recent numbers in the list. The numbers can be thought of as forming a stack, like a pile of plates. The most recent number goes on the top of the stack. An operator takes the appropriate number of arguments from the top of the stack and replaces them by the result of the operation.
In this notation the above expression would be
3 5 + 7 2 - *
Reading from left to right, this is interpreted as follows:
Polish Notation was devised by the Polish philosopher and mathematician Jan Lucasiewicz (1878-1956) for use in symbolic logic. In his notation, the operators preceded their arguments, so that the expression above would be written as
* + 3 5 - 7 2
The 'reversed' form has however been found more convenient from a computational point of view.
This file was last revised by Anthony Stone (ajs1@cam.ac.uk) on 3 June 1997.
I've always used an HP RPN scientific calculator. Started with an 11C, which was stolen. Replaced it with a 32S II about 17 years ago. I love to watch the response from non-tech borrowers. Where's the "equals" button? ;-)
Thanks, for years I've used RPN with my HP 12C.
I've often wondered how/why of RPN. It's all so common sense.