Next: RPN Tutorial Exercise 3, Previous: RPN Tutorial Exercise 1, Up: Answers to Exercises [Contents][Index]
‘2*4 + 7*9.5 + 5/4 = 75.75’
After computing the intermediate term ‘2*4 = 8’, you can leave that result on the stack while you compute the second term. With both of these results waiting on the stack you can then compute the final term, then press + + to add everything up.
2: 2 1: 8 3: 8 2: 8 1: 4 . 2: 7 1: 66.5 . 1: 9.5 . . 2 RET 4 * 7 RET 9.5 *
4: 8 3: 8 2: 8 1: 75.75
3: 66.5 2: 66.5 1: 67.75 .
2: 5 1: 1.25 .
1: 4 .
.
5 RET 4 / + +
Alternatively, you could add the first two terms before going on with the third term.
2: 8 1: 74.5 3: 74.5 2: 74.5 1: 75.75
1: 66.5 . 2: 5 1: 1.25 .
. 1: 4 .
.
... + 5 RET 4 / +
On an old-style RPN calculator this second method would have the advantage of using only three stack levels. But since Calc’s stack can grow arbitrarily large this isn’t really an issue. Which method you choose is purely a matter of taste.