John David Ratliff's Online Resume Site

[ Home | Résumé | Portfolio ]

Postfix Stack Calculator

Overview

This is a calculator which employs postfix notation and uses a stack to store its calculations. Postfix stack calculators and similar notational styles such as RPN, once learned, are much faster than using algebraic models.

Consider the following expression:

8 * 4 = 3

In Postfix, that would be 8 4 *.

Now, let's do a harder one:

2 + (3 * 8) - (4 + (48 / (4 + 2)) * 6)

We have to evaluate the parentheses first.

= 2 + 24 - (4 + (48 / 6) * 6) = 2 + 24 - (4 + 8 * 6) = 2 + 24 - (4 + 48) = 2 + 24 - 52 = -26

That is complicated for you and a calculator. Entering all the parentheses takes a lot of time. Consider the equivalent postfix notation.

2 3 8 * + 4 48 4 2 + / 6 * + -

How fast can you enter that last expression? I'm willing to bet it's much faster than you can find the parentheses for the first expression.

Features

License

Licensed under the GNU General Public License.

Learn more about GNU and free software at http://www.gnu.org/.

Download

calc.zip (16 KB)

 


E-Mail Me


Copyright © 2004-2012 John David Ratliff
All Rights Reserved

Get Firefox!    Valid HTML 4.01!    Made with jEdit