Post Reply 
NQ41 RPN Calculator
12-02-2017, 11:09 PM (This post was last modified: 10-04-2018 06:04 PM by Craig Bladow.)
Post: #1
NQ41 RPN Calculator
I've been working on a command line RPN calculator program that I'm calling "NQ41" which stands for "Not Quite a 41". Smile

With the release of version 0.01 the program supports continuous memory, running commands from an input file or STDIN and flags. Interactive mode is enabled by launching with ./nq41 -i

Version 0.011 the program supports 319 memories and all HP-41C functions not related to programming or alpha features.
Version 0.012 bug fix, Thanks Jim!
Version 0.013 CLX bug fix, again thanks to Jim!

If you are familiar with HP's RPN calculators such as the HP-25 or HP-41 then learning to use this program should not be difficult.
The math functions currently use the default double precision floating point libraries provided for these operating systems.

This is a command line client for OS X 10.8 and later, Windows 7/10 and Linux x86-64bit.

Download zip file for version 0.01: https://www.dropbox.com/s/gjfcy332s57loje/NQ41.zip?dl=1

sha256 of zip file for version 0.01: 3921e3a01ba01b0c6e4d1553e5193efd28e812ad649b5c8babd751b6782291b5

To confirm the sha256 checksum:
In OS X terminal: shasum -a 256 NQ41.zip
In Linux terminal: sha256sum NQ41.zip
In Windows: Install 7-zip, navigate to NQ41.zip, right click on it selecting "CRC->SHA-256" or use another utility that you trust.

After un-compressing the zip file, run 'nq41' from the folder corresponding to your computer's operating system.
For the Mac version, double clicking the .dmg file will mount and open virtual drive containing the application which you can run from a terminal session.
Depending on your computer's security settings you may have to take extra steps to approve running this program.

This is just the first step so I invite feedback on issues that people observe.

Code:

Andromeda:mac_osx craig$ ./nq41 -i
Welcome to NQ41 (Not Quite a -41!)
Version 0.10
Copyright (C) 2017-2018 Craig Bladow. All rights reserved.
This experimental software is released for the sole purpose of testing and feedback and without warranty of any kind.

Input commands and numbers, separated by spaces, and press return.
A space or return after a number is the same as the command 'enter'.
Use 'exit' to quit and 'cat 3' for a list of commands.

Memory cleared

> cat 3
 *, +, /, -, chs, 1/x, rup, rdn, x<>y, lastx, %, x^2, sqrt, enter, ln, e^x, log, 10^x, deg, rad, grd, pi, sin, cos, tan, asin, acos, atan, p-r, r-p, hms, hr, abs, int, frc, sum+, sum-, mean, sdev, sto, rcl, fix, sci, eng, clx, clst, clrg, prstk, trace, exit, cat, y^x, fact, about, mod, %ch, changes, hms+, hms-, e^x-1, ln1+x, rnd, st+, st-, st*, st/, sumreg, clsum, d-r, r-d, dec, oct, sign, x<>, view, wrts, reads, wrta, reada, sf, cf, fs?, fc?,

> changes
Version 0.003 Initial Release
Version 0.004 Added commands: mod, d%, changes, hms+, hms-, e^x-1, ln1+x fixed hr and hms.
Version 0.011 Added commands: rnd, st+,st-,st*,st/,sumreg,d-r,r-d, dec, and oct. Renamed d%, catalog, clreg, clstk, frac, pr, rp to %ch, cat, clrg, clst, frc, p-r, r-p. Implemented stack and indirect addressing. Statistics functions now 41C compliant.
Version 0.012 and 0.013 Bug fixes.
Version 0.010 Added commands: view, wrts, wrta, reads, reada, sf, cf, fs?, fc?.
        Added interpretation of commands from standard input or from a file.
        Added loading of memory and status from a file.
Usage:
For interactive mode: -i or -I 
To load memory from a file:  -l or -L filename
To run commands from a file:  -r or -R filename

x: 0.0000 y:0.0000 z:0.0000 t:0.0000 l:0.0000


> 5 45 sin sto ind y
x: 0.70711 y:5.0000 z:0.0000 t:0.0000 l:45.000

> 70 sin asin
x: 70.000 y:0.70711 z:5.0000 t:0.0000 l:0.93969

> 5 rcl ind x
x: 0.70711 y:5.0000 z:70.000 t:0.70711 l:0.93969

> 17 sto 0 42 sto 1 wrta all.mem 0 sto 0 sto 1 reada all.mem rcl 1 rcl 0
Writing all.mem
Reading all.mem
x: 17.000 y:42.000 z:42.000 t:17.000 l:0.0000

> exit

The following commands function the same, or similar enough, as in the 41C manual, with the disclaimer that the number representation and math functions are not identical: *, +, /, -, chs, 1/x, rup, rdn, x<>y, lastx, %, x^2, sqrt, enter, ln, e^x, log, 10^x, deg, rad, grd, pi, sin, cos, tan, asin, acos, atan, p-r, r-p, hr, abs, int, frc, sum+, sum-, mean, sdev, sto, rcl, fix, clx, clst, clrg, y^x, fact, mod, %ch, e^x-1, ln1+x, rnd, st+, st-, st*, st/, sumreg, clsum, d-r, r-d, dec, oct, sign, x<>

Differences:
hms+,hms- and hms will display the results of some operations differently so while the 41c would show 1.03 the NQ-41 would show 1.0260.
prtsk, same command but print to stdout, or console.
cat, just cat 3 works and not the same.
sci,eng, While these have some affect on the display, they do not work like the 41C.

Unique to NQ-41:
about, trace, exit, changes

Up Arrow to recall previous line entries works as follows:

MS Windows 7: just works
Linux and Mac OS X: Install a program called "rlwrap" and then run nq41 as follows:
$ rlwrap ./nq41

On Debian/Ubuntu/Linux Mint install rlwrap: sudo apt install rlwrap
On Mac OS X: First install Homebrew: https://brew.sh/
Then install rlwrap: $ brew install rlwrap

Check out NQ41!
Find all posts by this user
Quote this message in a reply
12-02-2017, 11:15 PM
Post: #2
RE: NQ41 RPN Calculator
nice work! Any repository?

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
12-02-2017, 11:25 PM
Post: #3
RE: NQ41 RPN Calculator
(12-02-2017 11:15 PM)pier4r Wrote:  nice work! Any repository?

A public repository is definitely on my roadmap, I would like a more complete feature set and more mature code benefiting from user feedback before uploading to a repository.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
12-16-2017, 03:20 AM
Post: #4
RE: NQ41 RPN Calculator
Version 0.004 released, see the first post for the download link. Version 0.004 Added commands: mod, d%, changes, hms+, hms-, e^x-1, ln1+x and fixed hr and hms functions.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
12-16-2017, 07:14 AM
Post: #5
RE: NQ41 RPN Calculator
Decimal arithmetic or binary?
(if you don't know, it'll be binary Smile


Pauli
Find all posts by this user
Quote this message in a reply
12-16-2017, 04:05 PM
Post: #6
RE: NQ41 RPN Calculator
It's binary arithmetic 64 bit floating point also known as double precision.

I have started down the decimal path more than once, in C and in Forth, and came to realization that since my goal was not to design an arbitrary precision RPN calculator such as 'dc', for the same number of bits, binary math allows a smaller epsilon than decimal.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
12-16-2017, 04:37 PM
Post: #7
RE: NQ41 RPN Calculator
Paul,

Actually some old posts of yours regarding converting decimal hours to H.MMSS were very helpful when I first thought I could fix the following:
Code:

> 2.05 hms
x: 2.0260 y:0.0000 z:0.0000 t:0.0000 l:2.0500

Where the answer I was expecting was 2.03 but ultimately one needs a special display mode for H.MMSS to solve this problem.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
03-01-2018, 02:41 AM
Post: #8
RE: NQ41 RPN Calculator
Version 0.011 released, see the first post for the download link. Version 0.011 Added many commands as well as indirect and stack addressing. Use the command 'changes' to see what was added.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
03-01-2018, 10:48 PM
Post: #9
RE: NQ41 RPN Calculator
Thanks Geir, I’ve updated the download link and I’m glad you like the program.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
03-02-2018, 04:48 AM
Post: #10
RE: NQ41 RPN Calculator
Version 0.012 released. Fixed a bug reported by the first known user yesterday. Geir's post brings the total known users to two, a 100 % increase! Smile

Check out NQ41!
Find all posts by this user
Quote this message in a reply
03-02-2018, 04:28 PM (This post was last modified: 03-02-2018 04:31 PM by Egan Ford.)
Post: #11
RE: NQ41 RPN Calculator
Feature requests:

1. ctrl-d to exit from prompt, common for UNIX/Linux CLI tool prompts
2. args to CLI, e.g. NQ-41 3 4 +, returns 7, no interactive prompt
3. support stdin, e.g. echo "3 4 +" | NQ-41, returns 7, no interactive prompt
Find all posts by this user
Quote this message in a reply
03-04-2018, 04:38 AM
Post: #12
RE: NQ41 RPN Calculator
(03-02-2018 04:28 PM)Egan Ford Wrote:  Feature requests:

1. ctrl-d to exit from prompt, common for UNIX/Linux CLI tool prompts
2. args to CLI, e.g. NQ-41 3 4 +, returns 7, no interactive prompt
3. support stdin, e.g. echo "3 4 +" | NQ-41, returns 7, no interactive prompt

Noted and thanks for the input!
The plan for the next few steps:
1. Bug Fix - CLX is supposed to disable stack lift temporarily, but stack lift is not enabled. Solution has been developed and I will release soon.
2. Add loading and saving of programs and do some restructuring of the program to better support different operating systems.
3. See about the requests above.
4. Add programming support functions such as LBL, GTO, etc.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
03-08-2018, 07:52 PM
Post: #13
RE: NQ41 RPN Calculator
(03-02-2018 04:28 PM)Egan Ford Wrote:  3. support stdin, e.g. echo "3 4 +" | NQ-41, returns 7, no interactive prompt

Regarding Item 3, what and how should results that affect X and Y or X,Y,Z,T and L?

For example: "5 5 r-p" returns 7.0711 45.000

Check out NQ41!
Find all posts by this user
Quote this message in a reply
03-28-2018, 03:06 AM
Post: #14
RE: NQ41 RPN Calculator
Version 0.013 released, see first post for download link. Bug Fix - CLX is supposed to disable stack lift temporarily, but stack lift was not being re-enabled.

Check out NQ41!
Find all posts by this user
Quote this message in a reply
04-13-2018, 10:29 AM
Post: #15
RE: NQ41 RPN Calculator
As said. Nice project that is pretty extended already! Sooner or later I will join the club "make your calc app on console" too!

Feature requests:
- git repo, or at least releases somewhere but not dropbox (assembla, wikidot, what not)
- continous memory.

Code:

$ /Applications/nq41
Welcome to NQ41 (Not Quite a -41!)
Version 0.013
Copyright (C) 2017-2018 Craig Bladow. All rights reserved.
This experimental software is released for the sole purpose of testing and feedback and without warranty of any kind.

Input commands and numbers, separated by spaces, and press return.
A space or return after a number is the same as the command 'enter'.
Use 'exit' to quit and 'cat 3' for a list of commands.

Memory cleared

> 16
x: 16.000 y:0.0000 z:0.0000 t:0.0000 l:0.0000

> 16
x: 16.000 y:16.000 z:0.0000 t:0.0000 l:0.0000

> 16
x: 16.000 y:16.000 z:16.000 t:0.0000 l:0.0000

> 16
x: 16.000 y:16.000 z:16.000 t:16.000 l:0.0000

> exit
x: 16.000 y:16.000 z:16.000 t:16.000 l:0.0000

$ /Applications/nq41
Welcome to NQ41 (Not Quite a -41!)
Version 0.013
Copyright (C) 2017-2018 Craig Bladow. All rights reserved.
This experimental software is released for the sole purpose of testing and feedback and without warranty of any kind.

Input commands and numbers, separated by spaces, and press return.
A space or return after a number is the same as the command 'enter'.
Use 'exit' to quit and 'cat 3' for a list of commands.

Memory cleared

>
x: 0.0000 y:0.0000 z:0.0000 t:0.0000 l:0.0000

>

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
04-13-2018, 06:23 PM
Post: #16
RE: NQ41 RPN Calculator
I've added 'Continuous Memory' to the feature list. This would have to be a feature that the user enables on the command line when starting NQ41, explicitly loading the memory/state file. For example, If I invoke nano (a simple unix text editor) and do not specify an input file, it opens in a blank state and does not open the last file.

Thoughts?

Check out NQ41!
Find all posts by this user
Quote this message in a reply
04-13-2018, 08:16 PM
Post: #17
RE: NQ41 RPN Calculator
Ok for me, but by default I'll set it on.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
04-25-2018, 12:49 AM (This post was last modified: 04-25-2018 01:18 AM by Craig Bladow.)
Post: #18
RE: NQ41 RPN Calculator
(03-08-2018 07:52 PM)Craig Bladow Wrote:  
(03-02-2018 04:28 PM)Egan Ford Wrote:  3. support stdin, e.g. echo "3 4 +" | NQ-41, returns 7, no interactive prompt

Regarding Item 3, what and how should results that affect X and Y or X,Y,Z,T and L?

For example: "5 5 r-p" returns 7.0711 45.000

I've solved this by implementing 'VIEW' which will output the referenced register to stdout. This is particularly elegant as VIEW can be used to view any memory, stack register as well as used with indirection.

Implementing input from 'stdin' means that an interactive session needs to be started by: "nq41 -i"
stdin can work as follows at least in Linux and probably OS X:
nq41 < file.txt
nqr1 <<< '1 2 + view x'

Check out NQ41!
Find all posts by this user
Quote this message in a reply
05-21-2018, 04:07 AM (This post was last modified: 05-21-2018 04:21 AM by Craig Bladow.)
Post: #19
RE: NQ41 RPN Calculator
Version 0.01 released, see first post for download link.
Added Continuous memory support via the commands WRTA and READA. Added support for input from STDIN as well as running commands from a file.
Initial support for flags, but not very useful until stored programs are supported.

For interactive mode you must now start the program as follows: ./nq41 -i

Check out NQ41!
Find all posts by this user
Quote this message in a reply
05-21-2018, 08:50 AM
Post: #20
RE: NQ41 RPN Calculator
Nice! I'll try on the mac at work. Also waiting for the git repo.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: cdmackay, 1 Guest(s)