Dec 182017
Combination rpn/financial calculator.
File 2-IN-1.ZIP from The Programmer’s Corner in
Category Financial and Statistics
Combination rpn/financial calculator.
File Name File Size Zip Size Zip Type
2-IN-1.DOC 6856 2572 deflated
2-IN-1.EXE 32576 31507 deflated

Download File 2-IN-1.ZIP Here

Contents of the 2-IN-1.DOC file

2-In-1 is a combination RPN calculator and financial calculator written in
Turbo Pascal 5.0.

The following primitives are supported:

+ plus
- minus
* times
/ divide
^ power
\ inverse
% percent
ln natural log
log log10
pi PI
e e
abs absolute value
int integer part
frac fractional part
mod modulus
chs change sign
sqrt square root
sqr square
sin sine
cos cosine
tan tangent
asin arcsine
acos arccosine
atan arctangent
hr convert HH.MMSSHH to decimal hours
hms convert decimal hrs to HH.MMSSHH
jdn convert YYYY.MMDD to julian day number
date convert julian day number to YYYY.MMDD
drop [n1 n2 ... n1]
dup [n1 ... n1 n1]
swap [n1 n2 ... n2 n1]
over [n1 n2 ... n1 n2 n1]
rot [n1 n2 n3 ... n2 n3 n1]
clst clear stack
clrg clear registers
! store to a register
+! add top of stack to a register
@ fetch from a register
fix set format for fixed display (e.g. 10.2 fix)
sci set format for scientific display
F! store to a financial register
[email protected] fetch from a financial register
[ ... ] summation i.e. [ 1 2 3 4 5 6 ] = 1..6

There is a ten register stack and there are an additional 10 scratchpad
registers (0-9). Up to 80 characters may be entered on a line with full
editing capabilities. RPN notation is used with a blank required as a
delimiter between numbers and operators. An example of a valid input line
would be
2 2 + sqr log
which would return the log of the square of 2 plus 2.
In the event of an error, the up arrow will re-enter the previous line for

Hex and binary support:

The calculator has limited support for hex and binary integer conversions.
For binary or hex integer input use a 'b' or 'h' suffix, e.g. 1011b or
0AFh. Note that hex integers with a first digit > 9 must start with 0. To
display the top stack register as a hex or binary integer you may use the
HEX or BIN command at the prompt. Binary and hex integers must be between
0 and 2^32-1.

Date support:

Date arithmetic is supported using the jdn and date operators. To get
the day of the week corresponding to a given calendar day, first convert it
to a julian day number then enter the command dow at the prompt to display
the corresponding day of the week [the day of the week is jdn 1 + 7 mod].
To do date arithmetic convert the dates to julian day numbers, perform the
calculations and then convert back to a calendar date if necessary. For
example to find the number of days between new year's and July 4, 1992,
do the following
1992.0704 jdn 1992.0101 jdn -
In this case, add 1 to give the day of the year, so July 4 is the 186th day
of 1992. The number of days remaining in the year after July 4 will be
1992.1231 jdn 1992.0704 jdn -
which is 180. To find the calendar day corresponding to 100 days after
March 1, 1992 enter
1992.0301 jdn 100 + date
giving 1992.0609 or June ninth.

Clearing the calculator window:

The calculator window may be cleared by entering the command CLS at the

Returning to DOS:

Quit by pressing escape at the prompt.

Financial functions:

The financial functions are invoked by pressing F3, then executing the
financial function needed. The standard convention that a negative
sign indicates a cash outflow is used. The compounding frequency (CF)
is the number of times the interest is compounded during the period implied
by the given interest rate, while the payment frequency (PF) is the number
of payments to be made during the same period. When no payments are involved,
PF = CF. For continuous compounding CF=PF=1. A monthly interest problem could
be stated using the annual interest rate divided by 12 or using the annual
interest rate and setting CF=PF=12. Note that the number of payments remains
the same, the number of months. The flags [D,E] and [B,E] indicate whether
calculations are based on discrete or contiouous compounding and beginning
or end of period payments. The default is DE, discrete compounding and end
of period payments.

The financial calculator stores its five arguments in financial registers
1-5. You may use the F! and [email protected] operators to move values between the stack
and the financial registers. If you are using the financial calculator
and need to do a calculation on the stack to determine a particular argument,
move to the appropriate register and press F3. This will return you to the
RPN calculator with the financial register number on the stack. Then do your
calculation, press return, and F3 again to return to where you were. To get
back to the RPN calculator you press escape while the cursor is on one of
the function buttons. Pressing escape while in one of the registers will
undo any changes made to that register and you will remain in the financial
calculator. Navigation around the financial calculator is performed using the
arrow keys, tab and shift-tab.

Help and stack/register display:

To get help press F1 at the prompt. Pressing F2 at the prompt will display
the stack and registers. Pressing any key will close the help or
stack/register window.


I have tried to trap potential error conditions, and if one is found
or if an unknown command is found in the command string, the string will
be written out with an underscore after the error. It is possible, however,
that errors such as numeric overflow will occur. To the best of my knowledge
all numerical algorithms are correct and work as described, however no
representation is made that such is actually the case. The calculator will
make use of a math coprocessor if one is present.


The help facility was implemented using the Technojocks Turbo Toolkit,
version 5.

Jason Olasky
874 New Mark Esplanade
Rockville, MD 20850
March 30, 1992

Registration + Source Code: $15.00
Comments and suggestions welcome, with or without registration.

 December 18, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>