
           RPNCalc - a small Reverse Polish Notation calculator

                           by Cyrille Chplov

                    Version 0.9 : September 11th, 1995


         Please excuse my poor English, as it is not my mother language.


1) Introduction
---------------

   RPNCalc was born to fit a single need : after years of addiction to Hewlett
Packard calculators, I felt unable (or too lazy) to go back to 'traditional'
calculators, such as Microsoft's CALC.EXE (the one shipped in Windows). Not that
I'm really unable to operate a $1 4-op calculator, but I just loose too many time
figuring out that I'm not in RPN mode. So I wrote RPN Calc. And as I found, after
investigating among my friends, that I'm probably not the only guy with this
'impairement', I thought it would probably not be a bad idea to release it.
Additionally, I decided to release the source so that anyone interested in knowing
how that works (or *why* this does not work as advertised <g>) could look under
the hood, and fix/break the thing.



2) Disclaimer
-------------

   The use of RPNCalc is entirely at your own risk - it runs flawlessy on
my computer, should run the same on yours, but if you encounter a problem, it's
yours. In particular, although I have done my best to ensure that the math functions
are accurate, you *must* check them thoroughly before trusting this program.

If you don't accept this, do not run RPNCalc !.


3) How does that work ?
-----------------------

If you are already familiar with the use of a HP calculator, you can probably
skip this paragraph.

In a traditional calculator, to do a simple operation such as 2+3= ?, you would
probably type something like : [2] [+] [3] [=], just as written, and get the result.

Reverse Polish Notation calculators do not work this way.
The core of those machines is what is called a stack. To get the result of 2+3,
one must first push the two operands (2 and 3), and then invoke the "+" operator.
both operands will be popped out, processed, and the result will be pushed back
on the stack. What, what, what ? not so fast - it's easier than what it looks at
first.

Let's try together :
At first, you should see an empty area, reading "empty stack". Let's fill it.

First, create the first operand, press the [2] button (or the [2] key of your
numpad), and push it on the stack, using the [Enter] key or button.
Create the second operand : press [2] [Enter]

At this point, you should see something like this in the stack :
     2:        2
     1:        3

The stack is viewed upside-down, so 1: is really the top of the stack. "under"
the 3, you have the 2. Now let's get the result : press the [+] key/button.
The stack should read :
     1:        5

Let's say now that you want to get the result of 1+2+3+4+5. Here comes in one of
the most powerful functions of the RPN stack (first press the [DEL] button to
empty the stack).

First, put all the arguments on the stack :
[1] [Enter] [2] [Enter] [3] [Enter] [4] [Enter] [5]

and now sum them : [+] [+] [+] [+]  -- presto !

you could do this another way, like this, for instance :
1 [Enter] 2 + 3 + 4 + 5 +


(by the way, the last [Enter]
can be ommited, so [2] [Enter] [3] [+] is valid)



 - Now what about more complex results ? Where are the parenthesis ?
 - They're unneeded
 - What ??!!
 - Really. Here's an example why :

Let's suppose you want the result of 4*(3+2).
On a traditional calculator, if you write : 4 * 3 + 2 =, you get 14, which is a
wrong result.
So you must override the priority of '*' over '+' by using parenthesis, and typing
4 * (3 + 2) =  to get the correct result, 20.

On a RPN calculator, you need no parenthesis. To achieve the result above, you would
have 'simply' typed 3 2 + 4 * ...  That is, you "evaluate" first the innermost
parenthesis, and then, go to upper levels.

If you press the blue arrow button next to the edit area, you'll see some classic
scientific functions. Most of them, such as the trigonometric functions, will require
only one argument on the stack - for instance, to get COS(25), you'd first make
sure that the calculator runs in degrees, then simply type : 25 and press the
[COS] button.

Some functions will require two arguments. In all cases, "x" refers to the
argument on the first level (1:), "y" being the second level (2:).

So to get the result of 2^8, you'd type 2 8 [y^x]

All this sounds complicated ? Hmm... Well, no surprise. It is always disturbing
at first - but if you get addicted to RPN, you'll have some hard time going back.



4) Stack management
-------------------

  To Drop the first argument on the stack, simply press the [Backspace] key, or
the ' <= ' button.

  To Swap the first two arguments, press the [SWP] button, or press the Left key.
You can drag some arguments from the stack to the "scrap" area on the "scientifc"
panel once you unfold the calculator.

  You can bring an argument buried in a deep level of the stack back to the first
level by selecting it, and then pressing on the "<-" button or the left key.


5) The sources
--------------

    As mentioned before, I included the source mainly to allow anyone finding a
gremlin in this program to be able to kill it - Although I did my best to limit
their proliferation, there are still probably several of these monsters hidden
somewhere in the code.

   Also, someone might be interested by how this works, and how to trick a Delphi
TList into a stack, by just overriding a few methods. This is in no way a fast
program - but in this case, the speed bottleneck is the human, not the computer.

   Unfortunately, I do not have time to translate comments from French into English
However, I tried to write clean code -- if something is unclear to you, I'll be
glad to clarify.

   Future evolutions might include the possibility to drag previously stored data
from the scrapbook back to the stack, Binary/Hexa/Octal/Ascii/Ansi conversion
support, and a support for typing commands and functions using the keyboards
instead of clicking on the math buttons.


6) Status of this program, how to contact me, etc...
-------------------------------------------------------

This program and its source are Freeware.

100420.1574@compuserve.com
FidoNet : Cyrille Chepelov@2:320/112
Flamenet, lawyernet : /dev/nul or \\.\device\nul

Thanks to my brother Pierre for the bitmaps he draws each time I need one.

5) Version history
------------------

September 11th, 1995 -- version 0.9   pre-release

EOF RPNCALC.txt

