Find what you need here.

Have you got the latest version? Check for updates.



Using the CLR and register swap keys to manage the stack of the free RPN calculator

This is the fifth page of this tutorial. If you skipped the first four pages, you might want to begin with the first page.

On this page we'll learn to use the CLR and register shift (x<>y) keys to manage the stack.
Free RPN Calculator The free calculator has just 19 keys:
  • Ten numeric digits (0-9)
  • One separator (the decimal point)
  • Five arithmetic operators
  • One <Enter> key
  • One CLR key, and
  • One register swap key (x<>y).

The calculator software that is currently included with every new Palm OS PDA, by comparison, has five more keys than the free RPN calculator. Yet, if you've worked through this tutorial, you already know that the free RPN calculator can do all that the Palm OS calculator does, and more! The Palm OS calculator doesn't do exponents and it has limited capability to handle nested calculations. That's the power of the RPN system. It allows you to do more with fewer keys.

We've already covered 17 of the 19 keys on the free RPN calculator, the two keys that haven't been covered are

  1. the CLR key, and
  2. the register swap key (x<>y).

The CLR key is easy to understand. It simply clears the content of the calculator's view window (a.k.a. the X register). No other internal registers are affected. It is important to note that the CLR key does not affect the contents of the stack, but there is a way to clear the stack.

The register swap key (x<>y) is a little bit more complicated. This key moves the content of the view window to the top of the stack (a.k.a. the Y register) and moves the old top of the stack to the view window. Why would you need to do this?

Well, you might remember that (back on page 2) when we first used the arithmetic operators, we learned that the order that the numbers are keyed into the calculator doesn't matter when we're adding or multiplying two numbers. But that's not true when we do division or subtraction.

So, in order to subtract two numbers, the number that you want to subtract from must be on the stack. What do you do if you want to subtract the number on the top of the stack from some number that you haven't keyed into the calculator yet? The solution to this problem is the register swap key. Using the register swap key, you can key in the number that should have come first and then swap it with the number on the top of the stack, and then press the '-' key.

Actually, if your calculations are well planned, and you always follow the rules for nested calculations (that I covered on page 4), you'll never need the register swap key, and, as your experience with RPN grows, you'll find yourself using it less and less. But, it's nice to have if you get yourself into a jam.

One last topic

There's just one more thing that you'll need to know to be completely proficient in the use of the free RPN calculator, and I'll cover that on the last page of this tutorial.
Google
How to clear the stack