Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 1.66 KB

example-details.md

File metadata and controls

25 lines (20 loc) · 1.66 KB

Example Details

The below example illustrates a stack as a vertical list of values where new values are pushed to the bottom of the list. This is to align to how old HP calculators illustrated the stack, i.e. by adding new values on the bottom.

These are the steps needed to solve the below equation using a RPN Calculator with details how the internal stack of the calculator would look before and after each operation.

((4+6) / (7-2) + 8) x 11 = 110
Stack before operation Operation Stack after operation
 
 
 
 
 
Push 4
 
 
4
 
 
4
 
 
Push 6
 
4
6
 
4
6
 
 
Add
 
 
10
 
 
10
 
 
Push 7
 
10
7
 
10
7
 
 
Push 2
10
7
2
10
7
2
 
 
Subtract
 
10
5
 
10
5
 
 
Divide
 
 
2
 
 
2
 
 
Push 8
 
2
8
 
2
8
 
 
Add
 
 
10
 
 
10
 
 
Push 11
 
10
11
 
10
11
 
 
Multiply
 
 
110
 
 
110
 
 
Result
 
 
110