[ID-PHy] » RPN & HP Calc
» RPN Calculator
Scientific and Business RPN Calculator
... with calculation edit and replay, infinite stack, full display, history navigation,
save, reload and print, user defined functions, conversions, ... and even a mouse keyboard ! Unmatched features for free !
» Download and/or Run latest version
» Installation instructions
» Complete User's Guide
» See also
HP-41C related topics :
Programming Environment, HP-IL Manuals and Bar Codes, links ...
» Et une petite initiation à la Notation Polonaise Inverse (ou RPN en anglais), si besoin en est.
As I cannot use another calculator than an HP like (this
is RPN logic), and as I always have my PC with, and no hand held calculator,
I wrote years ago, and recently enhanced, a small RPN Calculator program (in C). Looking at all
the GUI versions of the HP-41C, HP-25, ... I've seen, this is maybe very
ugly (run in DOS box, basic help, ...)
but it works, and "traces" all intermediates key strokes and results.
As you can see on the image here aside, I also took
some liberties with old classical HP calculators, adding 'Last y'
and allowing infinite stack. The "benefit" of the ugly DOS screen, is that
I tried to occupy it as much as I could, with valuable data instead
of graphical buttons (and anyway, I always want shortcuts to functions,
finding mouse operated calculators quite to slow !). And last, it fits about
130% of my daily needs, and if it doesn't, well, I open my source file
back and start writing !
In Version 5, I gave in "Progress pressure" and converted it for Windows 7, added a mouse keyboard, extending the DOS screen to 50 lines mode. Many thanks to Bill, who did nothing but requesting it ! ;-)
Sure you have a better one, but here it is :
The ZIP file contains the program file, help file and the example files (see below).
You can also directly test or use it pressing the "Run RPN Calc" button, the only limitation being that you'll not have the help file, so an error message will appear when invoking Help function.
New version Released on February 28th 2014 : CALCV50.EXE with new Help file (these are the two files you need). Now Windows 7 support and Copy result to clipboard added, Mouse driven, and vertical roll (with "mouse keypad" in 50 lines mode),with Conversions, User functions, ...
Previous version (under Windows XP and earlier) still available : CALCV41.EXE & Help file.
NB: Data file format changed (.RPN, .INI), delete them first (unpredictable results otherwise, sorry for that).
Help file has .TXT extension, with its own format (color tags).
V3.2 : Added : Scientific, Trigonometric, Finance and File
functions : SAVE and RELOAD (to replay your favorite calculation /
formula later on !) and PRINT. V3.2b : Added : Delete line from History. Bugs corrected.
V3.3 : Added : Scrolling in History window.
V3.4 : Added : Register re-naming. Help corrected (p,P intead of e,E).
V3.5 : Added : Auto-Save on Exit options and sexagesimal conversion (HH.nnnn <--> HH.MMSSssss).
V3.5b : Small bugs corrected (no decimal point recognized on Names clear (start, ...), ...)
V4.0 : Added : Mouse keypad, floating or exponent display format with number of digits.
V4.0a : Corrected : exponent sign 'E' related bug(s).
V4.0c : Change +/- and negative number entry; add Factorial; error handling.
V4.0d : Corrected : 10^X now works with real number (instead of integer part).
V4.1 : Added "User functions", Edit on result, Currency setup, ... (& re wrote parts of it)
V5.0 : Converted to run under Windows 7, mouse vertical wheel act as up/down arrow, copy to clipboard.
And how to run it with a single click ?
Installation instructions
Nothing to install, just copy the .EXE and new .TXT (help) files, or unzip package to where you want. The following only reminds (because everyone already knows this, of course !) how to associate an icon to it, and most important, how to configure it for mouse operated.
Here a quick tip, based on Windows 2000 (similar procedure under other Windows versions) :
- First copy a shortcut of the "DOS Box" (Command Prompt) to the "Quick Launch" bar (or anywhere else) : under Start / Programs / Accessories, drag the "Command Prompt" to your destination, and drop it with the Control key (CTRL) pressed (to copy it, instead of moving it). In Windows 98, drag "MS-DOS Prompt" under Start / Programs.
- Then right click on the icon, select "Properties", and under "Shortcut" tab, type the full path in the "Target" field (f.e. "c:\Your\path\to\CALCV41.EXE), click Apply and OK.
- Re-open the properties, they look like a little different now, and :
- under "General" tab, type a name (f.e. CALC).
- under "Program" tab, you should find back the previously keyed target under "Cmd line", set the same path in "Working" field and and re-type a name (may be different) aside the icon, run in "Normal window" and "Close on exit". The Working path is also where the .TXT, .INI and other saved files will be stored.
- to enable mouse operation, under Properties, Option tab, Edit Option : uncheck Quick Edit Mode.
- change any other parameter to fit your preferences (fonts, icon to identify it (if you need some, look in C:\WINNT\system32\pifmgr.dll),screen , ...) Note that you can configure other options through the menu while running.
- Click OK (and copy this updated icon to other places for your convenience : on you Desktop, anywhere in the Start menu, ...). That's it !
RPN Calculator V5.0 : User's Guide
CALCV50.EXE
Author : Pierre HARDY
Date : February 2014
Copyright (c) Pierre Hardy, 2014. All rights reserved.
The program and this document may be freely used and distributed.
E-mail author at: pierrehardy01@yahoo.be
Web site : http://id-phy.orgfree.com/
Table of Content
Versions history :
CALCV50.EXE : Version 5, Release 0; 28th February 2014
Converted to run under Windows 7
added :
- Copy to clipboard : Ctrl-C or double click on "Result"
- Mouse scroll = up/down
CALCV41.EXE : Version 4, Release 1; 5th August 2007
added :
- User defined functions
- Edit on results
- Currency rate and name customization
modif :
- Quick Help (now in separate file)
- .INI file name is version dependent
- Number format name and key changed form EXP to SCI (to avoid some confusion)
- ... many internal parts re-written / updated.
CALCV40d.EXE : Version 4, Release 0d; 3rd March 2005
modif : 10^X (10 to power X) works with real number (don't take only integer part anymore).
CALCV40c.EXE : Version 4, Release 0c; 12th December 2004
added :
- Factorial function
- Error handling (overflow, ...)
modif :
- Negative number entry (INSert key as sign toggle)
CALCV4_0.EXE : Version 4, Release 0; 29th August 2004
added :
- Mouse keypad in 50 lines DOS mode
- Floating (FIX) or Exponent (SCIentific) display format, with 0 to 9 decimal digits.
- No save option : quit without save
- Navigation in History with Pg Up/Down, Home & End
modif :
- 'E' no more valid as Exponent character (in numbers)
CALCV3_5.EXE : Version 3, Release 5; 30th March 2004
added :
- Auto-save options on Exit
- Conversion between HH.nnnnnn and HH.MMSSssss
CALCV3_4.EXE : Version 3, Release 4; 17th February 2004
added :
- Registers saved and re-naming option (also saved)
modif :
- Help corrected (p,P instead of e,E for e^x and 10^x).
CALCV3_3.EXE : Version 3, Release 3; 20th November 2003
added :
- Scrolling in History window
CALCV32b.EXE : Version 3, Release 2b; 18th November 2003
added :
- Delete line from History
modif :
- BUGs corrected (input 'E' after '.',
display of '-' sign with thousand separator, ...)
CALCV3_2.EXE : Version 3, Release 2; 10th November 2003
added :
- Histoy SAVE and RELOAD (Open)
- Print to TEXT file
- Trigonometric functions
- Finance functions
modif :
- Navigation (function keys changed, arrows to swap, ...)
- Display (no more special characters like arrows, ...)
CALCV3_1.EXE : Version 3, Release 1; 13th October 2003
added :
- Indirect memory operations,
- Increment memory, for ...
- History navigation, edit and replay (with lines
skip)
CALCV2_4a.EXE : Version 2, Release 4a; 2nd October 2003
added :
- 1/x, square, cube, square root functions
- support Scientific number notation (ex: 12e-7)
- '=' as Minus sign in number entry
- ',' as Decimal point
- partial memory operation display
CALCV2_3.EXE : Version 2, Release 3; 23 September 2003
added : Quick Help
Screen layout :
The screen is composed of a header (status line) and two display areas, plus an optional mouse keypad, from line 26 to 50.
NB : In the illustrated example, the Memory register has been renamed
as Index (for display only, see later for more information on register re-naming).
1. Header (Status line) :
The first line of the screen is dedicated to the header, with
the Title and "Help" on top of the History, and the Status
line on top of the Registers display.
On the Status line, are shown :
- First character indicate the 'Auto-save on Exit' mode :
(space) : Exit saving only User Functions & Currency (plus Click TimeOut)
. : Save User Fct and Status register
- : Save User Fct, Status and Register's Names on Exit
+ : Save User Fct, Status, Names and Registers on Exit
* : Save User Fct, Status, Names, Registers and Stack on Exit
# : Save User Fct, Status, Names, Registers, Stack and History on Exit
X : Exit without saving anything : simple quit
- User mode : USR | STD : Swap Fn with Ctrl-Fn key functions
- Number Format mode : FIX | Fix | SCI | Sci : Decimal numbers are displayed in FIX or SCI, all the same if FIX | SCI, and in mixed format (this is as when entered) if Fix | Sci.
- Display mode : REG & STK : Register or Stack 'priority'
- Trigonometric mode : RAD | DEG : Radian or Degree
- Finance modes/status :
BEG | END : payment
at Begin or End of period
- | * :
Finance registers are said synchronized (*), if one
has been computed based on the others, unsynchronized (-) otherwise.
YRL | MTL : Monthly
or Yearly annuities (payments)
The 'Memory Dump' (status, names, registers, stack and history) is stored in the
same directory as the program file, in CALC.INI.
Preferences are thus kept between calls.
2. The right one (usually, text in green on black) : traces all operations
(History) :
- Left column : entered numbers
- Central column : operations performed
- Right column : intermediate results
3. The left one (blue background) : shows all registers :
Result ... of last operation
Input ... field
Last y : 'Last Y' register (modified after each binary operation
on the stack)
Last x : 'Last X' register (modified after each binary or "unary"
operation on the stack, other than a memory function)
St n : Stack register n (0 = X; 1 = Y, 2 = Z,
... in an old HP like calculator). Note that 'Stack 0' (X register) is the
one shown as 'Result'
Memory : Direct (or One-key) memory, operated with F2
to F8 keys (referenced as Memory or Mem).
R n : Memory register n
Finance registers: when in Finance display mode
Number input, Format & Data type :
Number input
0 - 9 : Digits
= : '-' : Minus sign (displayed '-'), if entered in correct sequence
. or , : Decimal point (displayed '.')
e : Exponent sign (displayed 'E')
Insert : Toggle sign (-/+) of mantissa if 'e' not yet keyed, of exponent if 'e' keyed
Example : key stroke '=12,345e=67' will be translated to'-12.345E-67'
Backspace : correct input (work also on memory operations
partially keyed : if 'STO +.' already keyed, will successively remove '.'
and '+' then will exit memory operation)
Numbers format
F n : Fix (or Floating) mode, with n decimal digits : 1 234.5678
S n : Scientific (or Exponent) mode, with n decimal digits : 1.2346E+03
Data type
Each value (stack element, register, ... see next section) has an associated data type. This stores the number format (Fix or Sci, but not the number of displayed digits), or some specific formats like 'Percent' or 'HMS'. Data type are carried on with numbers when recalled & stored, but for now, no data type check is performed on operation, so you can add numbers in HMS and HR format, but the result will not be what you may expect : 1.5 + 1:30:00 will give 2:80:00 ! Just because 1:30:00 is internally 1.3000 and addition is done on its internal representation. In operations, the resulting data type is the one of previous 'X' register (this is data type of 'X' before operation occurred). To convert a 'Percent' to decimal, just multiply it by 1 (or add 0).
Basic functions :
F1 : Quick Help
+,-,*,/,ENTER
~ : ± : Change sign
% : Percentage (the original number keeps in the stack)
! : n! : Factorial X (must be positive integer)
i : 1/X : Invert
d : Delta % : ((X / Y) - 1) (displayed in %)
2 or ` : X2 : Square [small 2 superscript or grave accent
on keyboard, usually on the key at left of '1']
v : V¯ : Square root
q : X3 (X^3) : Cube
^ : YX (Y^X) : Y raised to power
X
l : ln(X) : Logarithm Neperian of X
L : log(X) : Logarithm in base 10 of X
p : eX (e^X) : e to the Xth power
P : 10X (10^X) : 10 to the Xth
power
<,> or LEFT, RIGHT arrows : Swap X and Y
UP, DOWN arrows : Scroll the stack
Backspace : Correct input, and if Input field is empty, clear
(delete) current stack element (this is Stack 0, also referred as the 'X'
register)
DEL : Delete input at once, and if input field is empty, will delete X.
ESC : Quit / Exit (work also on memory operations partially
keyed : will exit it directly)
Shift-F1 : Cycle on 'Auto-save on Exit' modes
Errors (divide by zero, negative argument for square root, ...) are displayed
(in red) in the input field and MUST be cleared with Backspace
or Escape.
Registers functions :
Internally (as coded), beside the History, we have two types of registers
: the stack elements (starting at Stack 0 for 'X', Stack 1 for 'Y', ...)
and the memory registers (Reg 0 to Reg 9, but also 'Last X', 'Last Y',
'Memory', Currency, Finance and "User function" associated registers). Each memory register has value, type and name properties.
Logically however (this is as presented), we have :
- the Stack : starting from 0, and "infinite", with its associated
'Last X' and 'Last Y' registers
- the Memory register
- the 10 Registers : from 0 to 9
- the Currency register
- the Finance registers (see Finance functions for more details) :
- N : Number of
annuities (or payments)
- R : Rate : yearly
interest rate in %
- P : Present value
- A : Annuity (or
payment)
- F : Future value
Clear/Display registers :
N : Clear Register's Names : reset to their default name (but not Currency and User Fct)
R : Clear Registers , including Memory and
Finance, but not 'Last X', 'Last Y' & Currency
K : Clear Stack, and thus 'Last X' & 'Last Y'
Y : Clear History
c : Clear Stack and History
C : Clear Registers, Stack and History
A : Clear All : Names, Registers, Stack and History
fc : Clear Finance registers only (see Finance functions)
fd : Display Finance registers : either on top (in place of)
some Register or Stack lines, depending on "Display mode"
D : Toggle Display mode :
- Stack : displays up to 20 stack entries, overwriting memory registers
if need,
- Register : always displays memory registers, limiting stack display to
9 entries.
M or Ctrl-Del : Memory reset (= "Factory settings")
Direct Memory :
Note : Memory can be accessed/operated either
by function keys (F2 to F8) or as other registers, using m as register number
(its actual number being 10, as shown in next table).
Its value is displayed next to 'Memory :'
x : Recall 'Last X'
y : Recall 'Last Y'
m : Recall 'Memory'
Registers / Stack operations :
s[+|-|*|/] <R> : Store (with optional operation)
to Register
r <R> : Recall Register
<R> : [.]<n>|i|x|y|m|n|r|p|a|f|c : specify
register as :
. : stack selector : refers to a stack
element if provided (optional)
<n> : register/stack number n,
from 0 to 9; or
i : indirect operations : register number
specified in Memory as : '(Integer part of the absolute
value of Memory) modulus 32'; meaning there are actually 32 registers (plus 'Currency' and 'Mouse TimeOut'), of which Finances ones, Last Y, ... (see table below). Indirect operations are valid only on registers, resulting in clearing
the stack selector ('.') if previously keyed.
x : 'Last X'
y : 'Last Y'
m : Memory register
n|r|p|a|f : Finance registers
Examples :
'ri' will recall register 3 if Memory
content is like *3.* (for example -23.9)
's+.5' will add X (current result) value
to the 6th stack entry (this is stack element number 5, as count start
from 0).
'sp' will set the Finance register 'Present
value' (will store X to ...)
NB: 's.x' produces the same result as 'sx',
and the same way, 'r.y' produces the same
result as 'ry' or 'y', and 'rm'
is equal to 'm'.
Partial memory operations are displayed in the Input field
and can be corrected (ESC / Backspace), this is as long
as the target register is not provided.
Register re-naming :
n <R>: Change register Name, where <R> is the register number, as in Store or Recall suffix (0..9, x, y, n, ... , c). To rename User Functions, press corresponding Fn key.
Default Name |
Calling key |
Register number |
R 0 ... R 9 | 0..9 | 0..9 |
Memory | m | 10 |
N Ann | n | 11 |
Rate/Y | r | 12 |
P Val | p | 13 |
Annuit | a | 14 |
F Val | f | 15 |
Last x | x | 16 |
Last y | y | 17 |
(Reserved) | | 18 |
(Reserved) | | 19 |
(Reserved) | | 20 |
(Reserved) | | 21 |
(Reserved) | | 22 |
(Reserved) | | 23 |
Usr F1 ... Usr F8 | [F1]..[F8] | 24..31 |
EUR>BEF | c | 32 |
(Mouse TimeOut) | | 33 |
You can change the default name given (displayed) to registers, but it will
not change the way you use them (same number / letter). Rename doesn't apply
to stack registers, neither to Input and Result fields.
This new name will be saved with the File Save function (see later), and on Exit,
depending on Auto-save mode.
Trigonometric functions :
First type 't' as prefix for any trigonometric function ('Trigonometric'
will be displayed in the input field), then :
r|d : Radian or Degree mode (status line updated)
p : Get 'Pi' value (3.141592...)
s|c|t : Sine, Cosine and Tangent
S|C|T : ArcSine, ArcCosine and ArcTangent
Finance functions :
Some theoretical background
Disclaimer : First, as finances functions are more complex to program
(not directly available in my compiler library) and as I'm not a financial
myself, it is quite more difficult for me to test them. Even if I
did my best, I'm just a little less than 100% sure of them. Especially the
'Rate' function, as there are no straight formula for it, and is computed
on an iterative way, by Newton-Rasphon method (thus requiring the derivate
of the function, not that easy ... after so many years without practice
!).
This said, the finance functions rely on (are derived or extracted from)
this general formula :
F(Rate, Nbr_Annuities, PV, Annuity,FV) =
PV * (1 + Rate)Nbr_Annuities + Annuity * ( 1 + Rate * Type)
* [ ( 1 + Rate)Nbr_Annuities - 1] / Rate + FV = 0 |
and, if Rate = 0 :
PV + Annuity * Nbr_Annuities + FV = 0 |
where :
Variable
Name |
Corresponding
Register |
Description / Remarks |
Rate |
R |
Yearly interest rate, expressed (entered) in percentages. |
Nbr_Annuities |
N |
Number of Annuities (or payments) |
PV |
P |
Present Value |
Annuity |
A |
Annuity (recurrent payment). I used the term 'Annuity'
and not 'Payment' just because 'Payment' and 'Present' start with the same
letter, making single character differentiation impossible ! |
FV |
F |
Future Value |
Type |
Status |
'Type' equals 0 (zero) if Annuities (payments) are due at the end of
the period, and is 1 (one) if due at beginning of it. |
In annuity functions, cash you pay out, such as a deposit to savings,
is represented by a negative number; cash you receive, such as a dividend
check, is represented by a positive number. For example, a $1,000 deposit
to the bank would be represented by the argument -1000 if you are the depositor
and by the argument 1000 if you are the bank.
Rates are yearly interest rate, meaning that with monthly payments
(annuity period set to monthly), the monthly interest rate used in annuity
function is first computed as :
Monthly_Rate = (1 + Yearly_Rate)1/12 - 1 |
If from the above F(Rate, Nbr_Annuities, PV, Annuity,
FV) function, we can easily get PV = FPV(Rate,
Nbr_Annuities, Annuity, FV), FV = FFV(Rate,
Nbr_Annuities, PV, Annuity), Annuity = FAnnuity(Rate,
Nbr_Annuities, PV, FV) and Nbr_Annuities = FNbr_Annuities(Rate,
PV, Annuity, FV); we can not get Rate = FRate(Nbr_Annuities,
PV, Annuity, FV) !
So, the only way is to compute an estimate value, by successive approximations
: an iterative process, finding the root of F(Rate,
Nbr_Annuities, PV, Annuity, FV), where Nbr_Annuities,
PV, Annuity, FV variables are fixed. I used therefore, the fast converging
Newton-Raphson method :
Ratei+1 = Ratei - F(Ratei,
Nbr_Annuities, PV, Annuity, FV) / F'(Ratei,
Nbr_Annuities, PV, Annuity, FV) |
where F'(Rate,...) is the
derivate by 'Rate' of F(Rate,...)
: dF/dr.
Operations
First type 'f' as prefix for any finance function ('Finance ... '
will be displayed in the input field), then :
c : Clear Finance registers.
d : Display Finance registers mode : Finance registers
are always shown.
b|e : Begin or End mode : payment are due at the beginning
or the end of the period (status line updated)
m|y : Monthly or Yearly mode : payment are due monthly or
yearly : affect the actual Rate used in formula, assuming it is stored
(status line updated)
r : Compute an approximation of Rate (iterative
process)
n : Compute Number of Annuities, based on other
arguments,
p : Compute Present Value, based on other arguments,
a : Compute Annuity (or Payment), based on other arguments,
f : Compute Future Value, based on other arguments,
When in Finance suffix wait state, the Finance registers are displayed,
as if Display Finance mode was active. Finance registers are displayed
on top of Stack register if in Register display mode, and on Registers
if in Stack display mode.
On successful completion of any Finance function, the status switch
from unsynchronized status ('-' indicator in Status
line) to synchronized status ('*' in Status line). The
Finance registers switch also from Magenta to Green color.
This way, one can immediately know if all arguments values are accorded,
or other said, if the following equation is true : PV * (1 + Rate)Nbr_Annuities
+ Annuity * ( 1 + Rate * Type) * [ ( 1 + Rate)Nbr_Annuities -
1] / Rate + FV = 0
The interest rates are input (and displayed) as a percentage value : for example, you key '3.5sr'
to store 3.5% as yearly interest rate, which is displayed as 3.5000%. Actually, numbers stored to r register are first divided by 100 (converted in %) if its data type is not already 'Percent', and is then associated with 'Percent' data type.
Other arguments are not converted, so, when working in monthly
mode, the Number of Annuities must be expressed (stored) in number of months,
and the Annuity amount is the monthly payment. Thus, if you want
to set directly the monthly rate (instead of the yearly), you just have
to stay in Yearly mode.
Again, as I'm not a financial, I don't know which options are
the more convenient. When switching from Yearly to Monthly, I could
as well automatically multiply the Number of Annuities ('N') register
by 12, and vice versa.
Conversions :
Currency conversions :
And as I'm Belgian, I "defaulted" the conversion Euro <->
Belgian Francs (Rate : 40.3399). You can change it by storing new rate in c register, and renaming it.
Currency name is structured in 3 parts :
- First 3 characters = from currency (default is EUR)
- Middle character : you should keep it as '>'
- Last 3 characters = to currency (default is BEF)
Those parts are use as currency conversion labels on 'Mouse Keypad', and as corresponding conversion functions (EUR>BEF or BEF>EUR, hence the importance of middle character).
£ or AltGr-b: convert from EUR to BEF (multiply by rate)
$ or AltGr-e (€) : convert from BEF to EUR (divide by rate). AltGr-e gives Euro symbol on most European keyboard (AZERTY ones).
Sexagesimal conversions :
Convert hour, degree, ... coding between decimal, with decimals representing the fractional part of hour,
and sexagesimal, where the two first decimal digits represent the minutes, the two next, the seconds,
and the remaining ones the seconds fraction.
As example, quart past two, is in decimal mode 2.2500 and coded in sexagesimal mode as 2.1500. After conversion, sexagesimal numbers will be displayed as 02:15:00.0000. In reverse direction, 67°30'45" must be keyed 67.3045, which is in decimal 67.5125.
h : convert from decimal (HH.nnnn) to sexagesimal (HH.MMSSssss), displayed HH:MM:SS.ssss
H : convert from sexagesimal (HH.MMSSssss) to decimal (HH.nnnn).
Metric to Imperial conversions :
Twelve conversions (in both directions) between metric and imperial systems are coded, but only accessible through the mouse keypad (no associated direct key).
m <--> ft cm <--> in gr <--> oz l <--> pt ha <--> acre l <--> US gal
m <--> yd km <--> mi kg <--> lb l <--> gal °C <--> °F km <--> NautMi
...
And now the
! ! !
You won't believe it !
I dreamed of it for
years, though about it for months and took some evenings to make it real
!
Navigation in History, Edit & Replay :
The "History" is the list of all operations keyed since ... last clear, showing all intermediate results : the right side of the screen on black background. This section will explain how to navigate in History, and how to edit and replay it.
To access History, just click on History (right zone) or press the TAB key.
History colors / Characters codes :
Color codes are used to visualize / remind any operation done on History (Delete, Edit, Skip, ... see further for details).
Then when printing to a TEXT file, the color codes are "translated" in Characters codes, and are written at the left of history line. The corresponding characters are stated between square brackets ('[]') hereunder.
Foreground color :
GREEN : as always, normal color for any history line
YELLOW : highlighted value
CYAN : edited value [>]
WHITE : highlighted & edited value
Background color :
BLACK : normal
GREEN : highlighted value
LIGHT GRAY : user functions.
And for operators / functions only :
BLUE : line deleted or input edited without replay : indicates that the result
is not correct ! [!]
BROWN : line (operation) marked to be skipped on replay [*]
YELLOW : line skipped in user function [*]
RED : break point : this operation and all following will be
skipped (until next break point) [#]
LIGTH RED : break point in user function [#]
CYAN : operations after/between break point(s) : indicates that
the operation is not performed [|]. This color is only shown after a replay. (Not marked in user functions).
Characters codes (when printing) :
> : Edited
! : Edited without replay
* : Skipped
# : Break point
| : After/between break point(s)
History Navigation :
ESC : Quit history mode
TAB : Switch to/from history
Arrows : Navigate in history, from value to value (input and/or
result)
Pg Up/Down, Home / End : Go one page up/down, go to top / bottom of History
F9 : Go to previous Edited value (if any), to top then bottom
of History
ENTER : Recall highlighted value
History Edit :
To edit, just go to any value (input or result field) and overwrite the highlighted value.
New input allows you to redo the calculations with other values, hypothesis (other scenario), while correcting result allows some adjustements : for example, if by computing you come to 24.89%, you could then consider 25% as better or easier value and overwrite the previous result.
Correct with Backspace, and if input field is empty, will quit
Quit with Escape at any time
Validate with any other. The operator is then set with
BLUE background.
DEL : Delete : Mark History line to be deleted. Operator will be replaced by DELETED on BLUE background until
next replay.
INS : Fix / Release result value. You can fix the current value, protecting it against updates with replay. Also, after having fixed or edited a result, you may want to release it back, so that it will be updated again on next replay.
History Replay :
F10 : Cycle over operation skip mode : Skip / Break / Normal
Skip : this line will be skipped on replay. The operator
is then set with BROWN background.
Break : mark as break point : from here, lines will be
skipped until end of history or next break point. The operator is then
set with RED background, and in between lines on CYAN.
F11 : Replay step by step. Press any key to run next line,
except ESC or F12 which will resume until last line.
F12 : Replay all (RUN !)
When "replaying history", ' *** REPLAY *** ' is displayed (in
red) in the input field.
If and error occurs during the replay, the error must first be
cleared (with ESC or BS). The operation will be skipped and marked
so, allowing you to correct and re-run.
Replay considerations :
When the first time I actually needed the history edit and replay, to make
some simulations, I came directly to the limit of it : I lost the result
of previous run ! This is why I then introduced the skip options and indirect
memory operations.
With indirect memory functions and the specially written Memory
Increment function (no effect on stack), each RUN can work on a different
memory register, and thus store the outcome in a distinct register.
The skip/break mode allows to only run once the Memory initialization,
and/or not replay the "post computing" of a RUN, or any undesired intermediate
operations ...
File functions :
To keep and replay the
fun for ever ...
Shift-F1 : Cycle on 'Auto-save on Exit' mode (see upper).
Shift-F2 : Save status, registers (value and name) and history to a binary file,
with skip info, ... allowing a "perfect" re-run afterwards (append
automatically the .RPN extension)
Shift-F3 : Reload and re-play (open) a previously saved
status and history from a binary file (append automatically the .RPN extension).
Note that Stack and History will be cleared on file reload. Registers (value and name)
will be restored before history replay (to restart from cleared registers,
start the operation with a 'Clear Registers', which don't affect names).
Shift-F4 : Print registers and history to a text file
(append automatically the .PRT extension)
NB: File names must respect old DOS rules :
maximum 8 characters before the extension (3 characters automatically added),
with no spaces, no special characters, ... Sorry for that !
But I must admit I use it !
Thanks to Bill who did nothing but requesting it !
Mouse operated :
Enable mouse keypad :
By clicking on the "up arrow" in the right top corner, you'll set the DOS box in 50 lines mode (instead of the standard 25), and a mouse keypad being displayed. You can also expand / reduce the window size (between 25 and 50 lines) with back slash character '\'.
Mouse operations :
Most mouse keypad buttons are self explanatory, and please refer to upper sections for details.
However, for convenience, some toggle keys (Save on Exit mode (Shift-F1) and Skip mode in History (F10)) have been split into direct functions/buttons.
On the other hand, all status indicators in the first line act as toggles :
- First character (' ', '.', '-', '+', '*', '#' or 'X') toggles on 'Save on Exit' mode
- STD | USR : User mode
- FIX | Fix | SCI | Sci : Number format :
F | S : Toggles between FIX and SCI mode
Last 2 characters (IX|CI) : toggles between Mixed and Same Format
- REG | STK : Display mode
- RAD | DEG : Trigonometric Degree / Radian mode
- BEG | END : Finance Begin / End of period mode
- YRL | MTL : Finance Yearly / Monthly mode
- *|- (between the two above) : Display finance registers
- HELP : Help in/out
- Upper right arrow : Mouse keypad enablement toggle
When in help, left click will move down.
Copy result to clipboard
New in V5.0, you can copy the result (in 'Result' field, X or Stack 0) to Windows clipboard by double-clicking on "Result" word (hence its highlighted blue background).
Recall value
Double-click on any displayed value (register, stack, history input or result) will recall it ! Note that double-click on history value works either in Navigation (History) or Calculation mode. Great, isn't it ?
Vertical scroll bar
I've added a scroll bar, to better see the History length, to see where we are in a long History.
You can click on up/down arrow to move line by line, or on scroll bar above/below the block to move by page. No block slide (drag), sorry.
Hidden tips
- By clicking on the 'c' of '(c)P. Hardy' in the title bar, you'll get a double ESC, which in most circumstances will get you out (Exit).
- In versions up to 4.1 : Ctrl-t shows (and set if number provided in Input field) Click Time Out. Actually, Click Time Out is used to determine double-click. The new value must be in the 10 - 200 range (default being 35), otherwise the current value is shown. The updated value is saved on exit (with Currency and User functions, as Internal registers). From version 5.0, mouse parameters are those of Windows configuration.
... and more functions, User defined :
New in version 4.1, you can now define your own functions, up to eight.
Definition
User Functions definition starts with a 'Label', ends with either a 'Goto' or 'Return' instruction and are stored in History. They are executed with corresponding 'Execute' function.
When defined (this is when Label is inserted), the corresponding key on 'mouse pad' is changed from gray to blue, as visual reminder.
On Replay, the Return instruction is automatically added at then end (of History), if a Label is still opened.
A Goto a not defined label, or to its own label, will give an error and operator will be marked "skipped". But the Goto will then still act as Return function (thus not actually skipped !). If the label is defined later on, just clear the skip mark (by pressing F10 2 times on it).
Keystroke & Mouse buttons
Alt-F1 ... Alt-F8 : Label 1 to 8
Ctrl-F1 ... Ctrl-F8 : Execute function 1 to 8
Alt-F9 ... Alt-F12 : Go to Label 1 to 4
Ctrl-F9 ... Ctrl-F12: Go to Label 5 to 8
Ctrl-End : Return instruction.
U : Toggles between User and Standard mode
With the mouse, click on Function number '1..8' (blue on white background) to insert a Label, on '>' (white on light gray) for Goto and on displayed name 'Usr F1..8' (blue on light gray) to Execute.
Naming & Display
Then you can rename the corresponding function (pressing 'n' then F1 ... F8), which both affect the key label (on 'mouse keypad') and operators in history.
Label, Goto and Execute instructions are displayed as their corresponding User function name, prefixed with a special identifier character :
Instruction | Prefix Character | Example with function (re-)named 'My Fct' |
Label | { | {My Fct |
Goto | > | >My Fct |
Execute | [ | [My Fct |
Return | } | }Return |
You'll need to Replay to see new names in history. User functions (from Label to Goto or Return) are on gray background.
To keep the History zone "clean", User functions at top of it are not shown. The first "dummy" visible operator is then '^^^^^^^', which is automatically added/inserted (and deleted in some cases) on Replay. You can still delete it manually if automation fails, but it will be inserted back on next Replay (or on restart).
User functions are not deleted with History. To remove them, delete their label first or do a "Full memory reset". In the same way, function names are not deleted (reset) with Clear Names function as long as the corresponding label exists.
User mode
And last, in User mode, F1 to F8 keys are swapped with Ctrl-F1 to Ctrl-F8, allowing direct access to user defined functions (F1 will execute function 1, and Ctrl-F1 will invoke help).
The best is still to try & play with !
Lastly ...
- The stack is "infinite" and "circular".
- Commands are now case sensitive.
- I make no warranties on the result of any mathematical, trigonometric,
financial operations, neither on any other functions, and will thus not be
liable for any damage the use of this program could cause, to your system
(file destruction, data lost), to your business (wrong operation result)
or what so ever ...
But be reassured,
- first it is not my intention ;-) (I coded the
plus function with the '+' operator of my compiler, and so on ...)
- and second, I use it daily, for business purpose as well, and never got any
problem.
But you also know that Error Free Program doesn't exist,
and God or Evil himself (I mean Microsoft) will surely not contradict me ;-)
(I know, it is not an example to follow ...)
Commented example
Basta con palabras ...
Lets look back at the example (quelque peu farfelu, je vous l'accorde !)
as in the figure or the PRINT file listed below. You can play with
it by yourself reloading it, here is the corresponding saved file
CALC41EX.RPN.
I illustrated here two independent calculations : trigonometric
operations and finance rates search.
Trigonometric operations
I computed here the Sine of fractions of 180° in Degree mode first,
then the same fractions in Radian mode, subtracted the two results to
check if were equal.
The fraction, (8.0000 on the second line of History area in the figure),
is in cyan because it has been edited, and the operation ('/' : divide)
is on blue background because I took the snapshot before re-running the
History (and indeed, the result at the right is not 180 / 8, but 45, 180/4,
the result of previous run).
After getting its Sine in Degree mode - and we are in Degree mode
because the Status is saved into the .RPN file and is restored on open/reload
- we switch to Radian mode, get Pi, divide it by the same value and took
its Sine. 'In-004' meaning that I went to the History,
and picked (recalled) the Input (left column) value, 4 lines
up. Again, as no re-run occurs, it still show the previous value
: 4 (and 180/4 = 45 : the result on second line !). Then, in early runs,
I swapped X and Y to see the two results on two consecutive lines, and
skipped
that operation afterwards (now on brown background, its 'result'
being out-of-date). Finally, the difference tells us if the two
calculations come to the same result (if you try with '6', you'll see a
difference of about 5.5E-17). Note that after a re-run, pressing the TAB
key will bring you directly back on last edited field, in this example
the divide factor.
Finance simulations
In the second part of the example, nothing to see with trigonometric part,
but to illustrate other functions, I compute and store interest rate simulations
for various numbers of annuities : for a loan of 2 000 $ I need, knowing
that I can reimburse 180$ yearly, and can make a final re fund of 200$
at the end, to which interest rate would correspond 10 to 20 annuities,
by increment of 2 years ?
First set the Finance registers (Present Value : 2 000; Future Value
-200; Annuity : -180 and initial Number of annuities : 10). Those operations
may then be skipped in subsequent runs, as they are initializations : STO
P and STO N flagged as break points (on red
background), operations in between being also skipped (cyan
background). The initial Number of annuities is then recalled (Re-001
: recall Result (right column) 1 (one) line up), added
to twice the content of Memory and stored again. Estimated interest
rate is computed (Rate) and stored in register specified in Memory
register : STO i. Finally, Memory is incremented by 1 (Mem+1)
so that next run will increment the number of annuities by 2 and will store
the result in next register.
NB : To replay excatly the sequence, after the reload, you should :
- Reload the CALC41EX.RPN file, which will re-run,
without Finance registers initialization;
- Clear registers : R
- Switch to History, and skip the Clr Reg operation
- Remove the break points at begin and end of initialization,
- Re-play it once
- Reset the break points.
Now, you can re-play it up to 10 times and get the Rate estimates stored in
Register 0 to 9.
I recommend you to run it once in step-by-step mode and see what happens,
how Status indicators changes (DEG to RAD, UNSYNCH
to *SYNC* and others if modes were different before reloading ...).
Print file
ID-PHY ================== RPN Calculator V4.1 ================== (c)P. HARDY
Result: 0.0785
Input :
Last y: 10.0000
Last x: 16.0000
Status indicators / Modes :
Auto-save on Exit mode : [#] Save all : Status, Names, Registers, Stack and History
Function key : Standard mode : F1 = Help , F2 to F8 = Direct Memory functions
Screen mode : Normal : Register and History only (25 lines)
Number format : FIX (Floating), with 4 decimals
Trigonometric mode : RADIAN
Finance mode : YEARLY payments at END of period
Finance registers are : SYNCHRONIZED (one being computed based on others).
Internal registers :
Click TimeOut 35.0000
Currency EUR>BEF 40.3399
Finance registers :
Present Value P Val : 2 000.0000
Annuity (payment) Annuit: -180.0000
Future Value F Val : -200.0000
Interest Rate Rate/Y: 7.8478 %
Number of Annuities N Ann : 26.0000
Memory registers :
Index : 9.0000
R 0 : 0.0000
R 1 : 0.0246
R 2 : 0.0412
R 3 : 0.0528
R 4 : 0.0612
R 5 : 0.0674
R 6 : 0.0721
R 7 : 0.0757
R 8 : 0.0785
R 9 : 0.0000
Stack registers :
St 0 : 0.0785
St 1 : 26.0000
St 2 : 0.0000
St 3 : 0.0000
=================== History ===================
180.0000 Enter 180.0000
!> 8.0000 / 45.0000
Sin 0.7071
Radian 0.7071
Pi 3.1416
In-004 4.0000
/ 0.7854
Sin 0.7071
* Swap 0.7071
- 0.0000
# 2 000.0000 STO P 2 000.0000
| -200.0000 STO F -200.0000
| -180.0000 STO A -180.0000
# 10.0000 STO N 10.0000
Re-001 10.0000
RCL M 8.0000
2.0000 * 16.0000
+ 26.0000
STO N 26.0000
Rate 0.0785
STO i 0.0785
Mem+1 0.0785
Quick Help
Quick Help is now (from V4.1) in a separate file (CALC_HLP.TXT), with its own format. You can edit it with any text editor, to add your comments, changes colors, ...
Here below, a reformatted extract of Help file, as displayed in Help function (without colors but with bold, ...) :
+---------------------------------------------------------------------+
RPN Calculator
An RPN calculator, working as old HP calculators
with infinite stack, trigonometric and finance functions,
conversions, editable & replayable history of operations,
user defined functions, ...
Author : Pierre Hardy
Version : 5.0, March 2014
More info at : http://id-phy.orgfree.com/CALC/CALC.html
Copyright Pierre Hardy, 2004 - 2014. All rights reserved.
The program may be freely used and distributed.
+---------------------------------------------------------------------+
Base Operations
Number Input :
0 - 9, e, . or , : Digits, Exponent sign, Decimal point
= : '-' sign (only if entered before digit)
INS : Change sign, anywhere in number input (+/- toggle)
<- / DEL : Correct / Delete, if empty input : delete x
Basic functions :
+, -, *, /, %, Enter : basic operators
~ : Change sign operator (end entry) i : 1/x : Invert
! : n! : Factorial(x) d : Delta % : (x/y)-1
` (back quote) or small 2 : Square v : v : Square root
q : x^3 : Cube ^ : y^x : y raised to power x
l : LN : Logarithm Neperian L : Log : Logarithm base 10
p : e^x : e to the Xth power P : 10^x: 10 to the Xth power
Stack movements :
<,> or LEFT, RIGHT arrows : Swap x and y
UP, DOWN arrow : Scroll stack
ESC : Exit
+---------------------------------------------------------------------+
Extended Functions
Accessed by pressing 'f' or 't' first
f : Finance functions : t : Trigonometric functions :
d : Display/Hide Finance Reg. d,r : Degree, Radian mode
b,e : Begin/End of period p : Pi (3.141592...)
m,y : Monthly/Yearly Annuity s,c,t : Sine, Cosine, Tangent
c : Clear Finance registers and S,C,T : ArcSin,ArcCos,ArcTangent
restore setting to End & Yearly
Computes (assuming all 4 other values are provided) :
n : Number of annuities
r : Rate (yearly rate in %)
p : Present value
a : Annuity (payment)
f : Future value
Negative value = Cash out
After execution of finance function, Finance registers changes form
Magenta to Green, and indicator in status bar switch form '-' to '*'
+---------------------------------------------------------------------+
Memory Operations
Direct Memory functions (on Mem register) :
F2 : Increment memory (+1) F3 : Store F4|m : Recall
F5 : Store + F6 : Store - F7 : Store * F8 : Store /
Stack and Registers operations :
x, y, m : Recall Last x, Last y or Direct Memory (Mem register)
s[+|-|*|/] : Store to (with optional operation [+|-|*|/]),
r : Recall ,
is : 0 - 9 : for Register number
.0 - .9 : for Stack number
x, y, m : for Last x, y or Memory
n,r,p,a,f : Finance registers (see Finance functions)
Numbers stored to 'r' are converted to %
c : Currency rate
i for Indirect : Register number specified as 'Mem mod 32'
Examples: s1 s*.2 s+y ri r.4 m sf x
Stack is infinite & circular.
+---------------------------------------------------------------------+
Rename, Clear, Save and Reload
Register rename :
n |[Usr Fn] : Set register or "User Function" Name (Press Fn)
File functions :
Shift-F1 : Cycle on Save modes Shift-F2 : Print to File
Shift-F3 : SAVE all to file Shift-F4 : RELOAD from file & Replay
Clear operations and 'Save on exit' options :
| CLEAR | SAVE
KEY/SAVE Flag |N R K Y c C A M| .-+*#X ' ' Clear all but :
User Fn & Cur| x|xxxxxx- - User Functions & names
Status Flags | x| xxxxx- - Currency rate & "name"
Names |x x x| xxxx- - Mouse TimeOut (Ctrl-t)
Registers | x x x x| xxx-
StacK | x x x x x| xx- 'X' Exit without saving
HistorY | x x x x x| x- => will restart as prev.
Ctrl-DEL or M : "Factory reset" or "Memory Lost" (~= .INI file delete)
Clear History also reset Trig. & Fin. modes to initial (saved) state.
Currency rate & User Functions & names are only cleared with Ctrl-Del
To clear User Function, delete its label then clear History (& Names)
+---------------------------------------------------------------------+
Conversions
Sexagesimal conversions :
h : HR->HH:MM:SS : conversion to sexagesimal
H : HH:MM:SS->HR : conversion to Decimal
Currency conversions :
Currency rate is stored in 'c' register : BEF/EUR in default example.
Corresponding name "EUR>BEF" used (needs a Replay after rename) :
- to re-label mouse keys as [EUR] [BEF] (at left of HMS)
- as Function name in history "EUR>BEF" or "BEF>EUR"
£ (Pound symbol) or Z : multiply by rate (to "BEF" or Local )
$ (Dolar symbol) or z : divide by rate (to "EUR", USD, ...)
Metric to Imperial conversions :
Only available through "Mouse pad".
+---------------------------------------------------------------------+
More functions ... User defined !
User Functions keys :
Up to 8 User Functions can be defined
Alt-F1...F8 : Creates a User Function (insert a Label in History)
Ctrl-F1..F8 : Executes corresponding User Function (if defined)
Alt-F9..F12, Ctrl-F9..F12 : Go to label 1-4, 5-8
Ctrl-End : Return (end function)
U : User mode toggle : Swap F1..F8 with Ctrl-F1..Ctrl-F8 functions
A function is terminated by either Return or Goto function.
Visually, functions are between { }, and grayed in History.
Mouse operations :
Click on : Key Number to insert a Label (define function)
'>' sign for "Go to"
Function Label (default is "Usr Fn") to Execute
When defined, function key color (on mouse pad) will change to blue
Function label (renamed) will be used in History (Replay to refresh)
User functions are stored in History, but not cleared with History.
Functions at top of History are "hidden" above screen, ending with
[^^^^^^^] : automatically added after last "hidden" function,
making it the first visible "operation" (can be deleted).
+---------------------------------------------------------------------+
... and now the MAGIC !
History Navigation :
ESC : Quit history mode TAB : Switch to/from history
ENTER : Recall value (and exit) F9 : Cycle on edited values
Arrows, Home, End, Page Up and Page Down : Navigate in history
History Edit :
Overwrite on input or result field, correct with Backspace
Quit with Escape and Validate with any other key.
Value set in CYAN and Operator set on BLUE until next Replay
DEL : Mark line to be DELETED INS : Fix / Release result value
F10 : Operation skip mode :
Skip (BROWN): skip one line
Break (RED) : skip until next break or until end
History Replay :
F11 : Replay step by step then ...
F12 : Replay all : Re-RUN / Refresh
+---------------------------------------------------------------------+
... MOUSE & Display ...
Mouse operation :
\ or Click on [Arrow] (upper right corner) : 'Mouse keypad' toggle.
Mouse Keypad should be self explanatory, most map to key strokes.
Double click on : - any value to recall it, wheel roll = [up], [down]
- text "Result" to copy result to clipboard
Status bar 'mouse toggles/keys' :
First characater : cycle on "Save on exit" mode
STD|USR FIX|Fix|SCI|Sci REG|STK RAD|DEG BEG|END YRL|MTL HELP [^]
-|* (between BEG and YRL) : Finance display (c) : Quick exit
F|S toggle between SCI|FIX, last two between Mixed & Same Format
Display format :
F n : FIX mode (n Decimals) S n : SCI mode (n Decimals)
# : Toggle between Mixed (Fix|Sci) and Same (FIX|SCI) Format
D : Display mode toggle : Stack/Register precedence (over Reg/Stk)
MixFmt : Mixed Format, numbers displayed as when entered : Fix or Sci
SmFmt : Same Format, all displayed as current setting : FIX or SCI.
Number of decimals applies to all. Refresh (F12) to update History.
+---------------------------------------------------------------------+
... in alphabetical order
Only direct key entry are listed here, not the suffix (store/recall),
subfunctions (like in Trigonometric, Finance functions).
a : A : clear All: names, reg, stk & hist.
b :
c : clear stack and history C : clear registers, stack and history
d : delta % D : toggle display mode Stack | Register
e : E character in numbers
f : finance functions F : Fix (Floating) display format
g :
h : convert to sexagesimal H : convert to decimal
i : invert : 1/x
j :
k : K : clear stacK
l : LN : logarithm neperian L : LOG : logarithm base 10
m : recall memory M : Memory reset
n : register re-Name N : clear register names
o :
p : e^x P : 10^x
q : cube : x^3
r : recall R : clear registers
s : store S : Scientific (Exp) display format
t : trigonometric functions
u : U : User | Std mode toggle
v : square root
w :
x : Last x
y : Last y Y : clear historY
z : From Currency conversion Z : To Currency conversion
0 - 9 : digits ,. : decimal separator
+ : plus - : minus
* : multiply / : divide
% : percentage ! : factorial
~ : change sign = : minus sign
^ : power ` , [small 2] : square
$ : From Currency conversion £ (Pound) : To Currency conversion
Ctrl-c : Copy Result to clipboard
\ : Mouse pad toggle # : Mixed | Same Format mode toggle
ESC : quit / exit TAB : to/from History
Function keys
F1 : Quick Help Shift F1 : Cycle on Save mode
F2 : Mem + 1 Shift F2 : Print
F3 : Store to Mem Shift F3 : Save
F4 : Recall Mem Shift F4 : Reload
F5 : Store + Mem
F6 : Store - Mem
F7 : Store * Mem
F8 : Store / Mem
F9 : Go to previous edited
F10 : Toggle skip | break | normal mode
F11 : Step by step run
F12 : Replay : run all
Alt-F1..F8 : Label 1 .. 8 Ctrl-F1..F8 : Execute Fct 1 .. 8
Alt-F9..F12 : Go to 1 .. 4 Ctrl-F9..F12 : Go to 5 .. 8
To conclude ...
This program is "freeware",
but if you download and test it, could you provide me some feedback. Suggestions
on key mapping, new functions, mouse keypad layout (I'm not 100% satisfied of it), ... are welcome. I'm thinking about extended finance
functions, add statistic functions, ... So if you have some
requirements, I just make no promises ;-)
I'd like to know who uses it, so I could add you to the users list and inform you of new "releases". Take one minute to drop me an e-mail !
Pierre HARDY.
e-mail : pierrehardy01@yahoo.be
Copyright © Pierre Hardy, 2004 - 2014. All rights reserved. The program
and this document may be freely used and distributed.
(5 - 01/07/2014) ¤