View the code here.
A brief explanation of Reverse Polish Notation:
Infix notation is what you are most likely familiar with. It looks like this:
4+5+6 = 15
However you end up with issues of order-of-operations with infix notation, such as:
4+6/2 could equal 5 or 7 depending on the order of operations
Reverse Polish Notation makes it so each operator is preceeded by exaclty two operands. Example:
4 5 6 + + = 15. To make it clearer, here are parenthesis:
(4 (5 6 +) +)
So you will never have order-of-operations issues. Example:
4 6 2 / + = 7, or 4 6 + 2 / = 5
EXPLANATION OF FUNCTIONALITY
- Higher text boxes contain more recent stack entries than lower text boxes.
- Each operator takes two arguments except for sqrt.
- If you try to push a value with improper syntax it will be tossed out.
- The ce/c button clears all fields and resets display0 to "0.0".
- If you try to use a binary operator such as + when there are fewer than 2 operands it will ignore it.