RPN Calculator 2.0 for Rex 6000

New RPN is here: RPN 2.0 Alpha -- August 15, 2002
The source code is here (zip, 50 kB) (not for the faint hearted).

 

Alpha release -- 08/15/2002 21:50:05
[fast and dirty preliminary documentation]


What's new
==========

Two prefix keys -- INV (Invert) and HPR (Hyper, the
name 'hyp' doesn't fit on the button) Sometimes they
really mean inverse and hyperbolic functions

Much more functions implemented (see list below)

Date/time operations, H:M:S representation, Modified
Julian day, Weekday calculation, Moon phase

Customizable unit conversions
RPN reads memo RPN_cnfg (see sample, will be completed)

Entering any numbers with just number and dot keys

Memory cells m1 and m2 are mapped to all memory pull,
their buttons are INV and HPR

Of course, the "dll" (RPN_gear.rex) is also new.

Holding HOME switches the power off but saves your "session".


Keyboard functions
==================

                      INV         HYP         INV+HYP
---------------------------------------------------------
MX        m1 <> x     m2 <> x
M+        m1 += x     m2 += x
MS        m1 = x      m2 = x
MR        x := m1     x := m2
/         y / x       GCD         mod
*         y * x       LCM         par        
-         y - x       {x}         cat
+         y + x       [x]         hyp
+/-       -x          WkDay       MnPhs
sin etc.  sin,cos,tan arc...      sh,ch,th    ar...
ln        ln(x)       exp(x)      lb(x)       2^x
lg        lg(x)       10^x
^         y^x         log(x,y)
^2        x^2         sqrt(x)
pi        3.1415...   1.6180...   0.5772...   299792.458
x|y       x <> y      rot down    rot up
1/x       1/x         n!          nCr         nPr
>R        Deg>Rad     Rad>Deg
>C        °F>°C       °C>°F       MJD>Unix    Unix>MJD
##        Input       »Hex        »Time       »Date/Time
CE        x = 0       clr.stk
<--       del,drop
ENT       enter,dup
Dat       not implemented (yet?)


Functions description
=====================

(mainly, differences from 1.6)

GCD    greatest common divisor, x & y must be natural
LCM    least common multiplier, x & y must be natural
sqrt   square root of abs(x)
{x}    fractional part of x
[x]    integral part of x, floor(x)
mod    y mod x, numbers may be not integer, y - x * floor( y/x )
par    parallel sum (or resistors, e.g.) x*y / (x+y)
cat    (hyper-diff) cathet, sqrt( y*y - x*x ), e.g. 13,12 or 12,13 --> 5
hyp    (hyper-sum) hypotenuse, 333,444 --> 555
WkDay  calculates week day for a MJD (see below) 0=Sun 1=Mon etc
MnPhs  Moon phase, age 0 to 29.5305886 days, +/- 0.6 days
lb(x)  log base 2
>C     convert American degrees to normal (yes, it's here for fast access)
>Unix  convert MJD to Unix time (dates from 1.1.1970 to 1/19/2038)
Input  enter number from keyboard (see Input Formats below)
»Hex   show number as hexadecimal (0 to 68719476735)
»Time  Show x as hour:min:sec (or deg:min:sec)
»D/T   Show x as if it's MJD, show Month/Day/Year H:M:S
pi     pi, golden ratio, euler constant, light speed
n!     factorial, for integers 0..33 only
nCr    n!/((n-r)! * r!), n may be greater than 33
nPr    n!/(n-r)!, n may be greater than 33
RotUp  (top)x,y,z --> (top)z,x,y
RotDn  (top)x,y,z --> (top)y,z,x


MJD
===

This is a date in form of Modified Julian Day. It differs from
Julian Day by 2400000.5 (see http://tycho.usno.navy.mil/mjd.html)
0 MJD is 11/17/1858, 50000.04309 is 10/10/1995 01:02:03
Don't forget, if you add time (HMS) and date, divide time by 24!
So, this allows you to perform any calculations with date and time!


Entering numbers
================

You can enter any value with just digits 0-9 and dot. First time
you press dot, a decimal dot is put. Second time it's 'e', and the
third time it enters '-' in the exponent.
1 2 . 4              enters 12.4
1 2 . . 4                   12.e4 i.e. 12e4
1 2 . . . 4                 12.e-4 i.e. 12e-4
1 . 2 3 4 5 . 1 2           1.2345e12
1 . 2 3 4 5 . . 1 2         1.2345e-12

You can use backspace <-- to edit the number while entering it.


Input Formats
=============

Key ## will pop up the keyboard and allow you to enter any number
forms including hexadecimal, times (or degrees with min and sec)
and dates. '@' starts hexadecimal number, '/' indicates dates,
colon ':' (or semicolon ';' in order not to switch keyboard)
indicates HMS form. Time may follow date after one space. Compo-
nents of date and time may be floating point numbers. I don't
like to put here BNF, you'll catch it by examples:

@100                   256
@FeDcBa789             68414056329, same as @fedcba789
10:15                  10 hours/deg 15 minutes, 10.25
10:15:30               10 deg 15 min 30 sec, 10.25833333
10;15;30               same
10;15.5                same
1;2;3                  1:02:03
0;0;1.2345             3.429166667e-4, 1.2345 seconds
;;1.2345               same
1/1/1970               40587 (it's MJD)
01/01/1970             same
1/1/1970 12            40587.5
1/1/1970 12;00;00      same
1/1.5/1970             same
8/15 21;24             52501.89167 now :-)  year 2002 default


RPN_cnfg Format
===============

# as the first character introduces comments
Empty lines are allowed and ignored
A line contains a one-char command, a blank, and a string or
a number. A # comment may come after numbers.
Commands are:
 c categories -- "main" convert menu, categories list
 u units -- "from" and "to" (2nd and 3rd level) menus
 n number -- well, a rate for a unit; may be floating point
There may be up to 10 categories with up to 10 units each.
A grave accent (`) splits a line for display.


Conversion mode
===============

Key cnv enters the unit conversion mode. It's a sequence of
SuperCalc-like menus, of three levels -- Categories, From and
To. You chose what you want with digits 0 to 9 and you can
return to a previous level with <-- or cancel the conversion
mode with CE or cvt. For example, if you have this RPN_cnfg

# RPN conversion config file
c 0:Money 1:Length
u Money -- 0:Bucks 1:Euros
n 1.0
n 0.9667
u Length -- 0:m`1:yard
n 1
n 0.9144
#EOF

Then 2 3 cvt 1 1 0 will convert 23 yards to meters (21.0312).


Known Issues
============

No error checks, almost never! Neither in functions, nor in
config reading. Please be careful yourself!


Internationalization
====================

There exist version with ASCII (7 bit) characters on the keyboard

There exist version with European (dd/mm/yyyy) dates input/output

Ask me if you need these builds.


Plans
=====

Allow it to hide in Rex's Calc place

Put access to memory cells 0..40 (or 0..100) to HYP-M keys instead
of display touching

Normal documentation

Normal real life RPN_cnfg

Exchange »Hex and »Time?

No more functionality planned


Contact
=======

 


Copyright © 2002 by Georgy Pruss

 

 

 

 

 

 

 

 

 

Old Version

I'm sorry but sometimes the conversions in 1.6 may crash
and/or may lead to hiding all addins after exiting RPN.
Pin reset does help in this case.

You can have both versions here: RPN 1.5 and RPN 1.6


RPN Calculator
Version 1.5
07/16/2002

(This is the first public release, so it's kinda beta. So
please do expect fixes/changes soon. And I've had Rex for
just a week!)

This is a simple RPN (Reverse Polish Notation) calculator.
(RPN means it's stack-based and you first enter numbers on
the stack and then operate on them. So, in order to add 3
to 20 you first enter 3, then enter 20, then order: add!)
It has a stack of three numbers, 2 memory cells, 40 storage
cells, 40 unit conversions, all usual math operations,
11 or 12 decimal digits precision (exponent -38 to +38),
input and display in hexadecimal notation. Error detection
and report is rather primitive because of memory limitations.
The calculator uses math functions from a separate math
library addin (provided).

The upper pane is "display". It shows the stack on the left
(z, y, and x. x is the top of the stack, but as it usual in
computer science, is at the bottom. And the trees grow usually
upside down. The top is in bold) and two memory cells on the
right, if they are not empty. Also the right part is used to
show hex/char representation and messages.

The active elements are 40 buttons and the "display" -- use
its left half to store a number and the right part to recall.
(Think of it as "get from stack", which is on the left, and
"get from memory" which cells are on the right)

To exit, press any hard button or any application icon.

The "modes" of work are:

* entering numbers with buttons 0 to 9 and . (dot) Sorry, no
  exponent and/or sign and/or rational numbers entering yet
* performing normal function, which is shown on the buttons
* performing inverse (or additional) function, which are not
  shown, but are quite obvious and are easy to memorize
* entering hexadecimal number -- the standard keyboard is used
* performing direct or inverse unit conversion -- the keyboard
  layout will show the units.
* storing/recalling numbers in "big" memory.

The calculator has ASCII and "Native Rex" versions. ASCII uses
only characters with codes less than 128 and must be used if
you burned other language font in the upper part of fonttable.

To store/recall numbers

Tap on the left or right part of the display and then on any
button (40 memory cells!). If you changed your mind and don't
want to store/recall the number, just tap on the display again.

The keys and their functions are:

inv  turns on and off the "inverse" mode

cvt  turns on and off the conversion mode and switches the
     keyboard. These both modes can be used together and in
     any order.

0-9  well, I won't explain it, should I?

.    that's a bit more tricky, but you'll manage it too

AC   clear the stack

CE   clear the input

<--  delete last character when entering, or drop the top
     number from the stack

ENT  separate numbers when entering, or duplicate the top

The other keys have different meaning in different modes.
Again, x is the top of the stack.

     NORMAL                     INVERSE

MX   exchange x and m1          exchange x and m2

M+   add x to m1                add x to m2

MS   store x to m1              store x to m2

MR   recall m1 to the stack     recall m2 to the stack

+    add two numbers, x and y   integral part, [x]

-    subtract x from y          fractional ppart, {x}

*    multiply x by y            sign of x, i.e. -1, 0, 1

/    divide y by x              y modulo x, 3.1 mod 2 = 1.1

+/-  change sign                absolute value

sin  sine, argument in radians  hyperbolic sine, sh

cos  cosine                     hyperbolic cosine, ch

tan  tangent                    hyperbolic tangent, th

atn  arctangent                 hypotenuse: sqrt(x*x + y*y)

ln   natural logarithm          exponent, exp(x)

log  base-10 logarithm          10 raised to a power x

^    power, y^x                 root, y^(1/x)

^2   square, x^2                square root, sqrt(x)

pi   3.1415926535897932,,,      1.6180339887498948482...

x|y  swap x and y               rotate the stack down

1/x  reciprocal value           factorial (up to 33!)

>R   convert deg. to rad.       convert rad. to deg.

>C   convert *F to *C           convert *C to *F

HX   show as hex and char       enter as hexadecimal

In the conversion mode, the direct convertion is to SI, and
the inverse conversion is to US/GB measures. The keys are:

inv  ...  brl  UK   psi  in  in' in"  acr  BP
lb   oz   *oz  *oz  psf  ft  ft' ft"  (g)  RR
tns  pin  *pi  *pi  o/g  yd  yd' yd"  hp   UH
tnl  gal  *gl  *gl  l/f  mi  mi' mi"  nm   ISh

Let's go by columns...           ...and the values

1.Mass       2.Dry Volume

inv on/off   (back to normal)
pound -> g   ounce -> ml          453.5924  28.3495
Ton(short)   pint to litre        907.1847   0.5506
Ton(long)    gallon to litre     1016.0469   4.4050

3.4.Liquid volume, US and UK

barrel (oil) troy ounce -> g      158.9873  31.1035
fl.ounce     fl.ounce   -> ml      29.5735  28.4130
fl.pint      fl.pint    -> l        0.4732   0.5682
fl.gallon    fl.gallon  -> l        3.7854   4.5460

5.Preasure/Density

Pound per sq.inch -> kPa            6.8947
Pound per sq.foot -> Pa            47.8800
oz/gal                              7.4890
lb/ft3                             16.0190

6.Length     7.Area

inch -> cm   sq.inch -> cm2         2.5400   6.4516
foot -> m    sq.foot -> dm2         0.3048   9.2903
yard -> m    sq.yard -> m2          0.9144   0.8361
mile -> km   sq.mile -> km2         1.6093   2.5900

8.Volume

cub.inch -> cm3                    16.3870
cub.foot -> litre                  28.3168
cub.yard -> litre                 764.5549
cub.mile -> km3                     4.1678

9.Misc      

acre --> m2                      4046.8630
g (gravity)                         9.8067
horsepower                        745.7000
nautical mile                       1.8520

10.Currency
           
Brit. Pound                         1.5648
Rus. Ruble                          0.0317
Ukr. Hrivna                         0.1877
Isr. Shekel                         0.2145

Well, in general, I made what I needed or going to use.
But your suggestions are welcome anyway.

To do:

whole:min:sec, dates parsing
display 6-hex 8-oct 2-bin 0-hms 1-date,time
load/save workspace
is_prime, nth_prime, gamma, perm, comb, NOK, NOD, min, max
programming/scripts, configuration/customization etc.

Please report any bugs, suggestions, and spelling corrections!

The program, the math library and the documentation are
copyrighted and should be licensed for commercial use.

Thanks to all the Rex 6000 community!!!

G-: