The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Reverse Polish Notation in Calculators

Date: 09/17/2005 at 14:14:09
From: Varda
Subject: What are stacks, pushing, and popping?

"My first calculator used something called 'reverse Polish notation',
which allowed you to do operations without using parentheses, but
then you had to be very careful about the order in which you entered
numbers and operators.  You learned about stacks, and pushing and

I came across this quote in an email.  I've never heard of "stacks,"
"pushing," or "popping" before in my life.  Can you translate?

Date: 09/17/2005 at 22:55:54
From: Doctor Vogler
Subject: Re: What are stacks, pushing, and popping?

Hi Varda,

Thanks for writing to Dr. Math.  A stack is a way of organizing data,
used frequently in computers.  Think of it like a stack of dishes. 
You put dishes on the top of the stack, and then you take them off the
top of the stack.  Notice that the first one to come off is the last
one that you put on.  When you put something on the stack, you say
that you "push" it on the stack.  When you take something off, you say
that you "pop" it off the stack.  So "pop" takes one thing off the
stack (and typically uses it in some way), while "push" puts something on.

Hewlett Packard made a line of very nice calculators that confused a
lot of people by using this "reverse Polish notation," which means
that the operation comes after the number, instead of in between them:

  5 7 +

instead of

  5 + 7.

In these calculators, you might enter something like

  5 3 4 * 8 + +

to mean

  5 + ((3 * 4) + 8).

Each time you enter a new number, the calculator pushes it on the
stack.  Each time you enter an operation (like * or +), the calculator
pops two numbers off the stack, does the operation, and then pushes
the result on the stack.  See for yourself what things go on the stack
each time you enter a symbol from the above list, and see why it
results in the computation I wrote.

It takes some getting used to, but it can be really convenient if you
are used to it.

If you have any questions about this or need more help, please write
back and show me what you have been able to do, and I will try to
offer further suggestions.

- Doctor Vogler, The Math Forum 

Date: 09/18/2005 at 00:56:20
From: Varda
Subject: Thank you (What are stacks, pushing, and popping?)

Thank you so much!

Your example was really clear and tied together your verbal 
explanation perfectly!  You know, I think that, given practice, my
math-disabled self would find the reverse Polish notation fairly
intuitive.  At least more so than trying to remember the standard
order of operations.
Associated Topics:
Elementary Number Sense/About Numbers
High School Calculators, Computers
Middle School Number Sense/About Numbers

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.