Post Reply 
Sharp PC-G850VS
06-11-2021, 07:35 AM
Post: #151
RE: Sharp PC-G850VS
(12-18-2020 07:48 PM)robve Wrote:  The PC-G850 can be nicely used as a calculator, albeit in BASIC, which is cumbersome.

Attached is an RPN Complex Calculator I wrote that emulates the HP-15C. The display shows the T,Z,Y,X stack and its "imaginary stack" S,K,J,I. All of the PC-G850 function keys work. Like the HP-15C it has complex arithmetic, 2-var statistics, STO/RCL registers, and can be extended with BASIC programs (see source code). I also threw in some extra features, such as rational approximation by continued fractions.

[Image: Screenshot_20201218-104116.png]

RUN to start, clears registers
GOTO*R to resume without clearing registers

Keys for operations and functions:
A abs, |XI| -> XI
C ceiling, ceil(XI) -> XI
E x10^ (when entering a number)
F fraction, frac(XI) -> XI
G GCD, gcd(Y,X) -> X
H hyp prefix to [arc]sin,[arc]cos,[arc]tan
I enter imag part / back to real part
J same as I (for engineers)
L linear regression, slope and intercept -> Y,X
M mean of y and x -> Y,X
N floor, floor(XI) -> XI
Q quotient and remainder of Y/X -> X,Y (quotient in X, remainder in Y)
R rational, X -> Y,X such that Y/X approximates the given X within 1E-10
S stddev Sy and Sx -> Y,X
T truncate, trunc(XI) -> XI
V variance of y and x -> Y,X
Y linear estimation of r and y given X=x -> Y,X
^ raise, YJ^XI -> XI
+ add, YJ+XI -> XI
- subtract, YJ-XI -> XI
* multiply, YJ*XI -> XI
/ divide, YJ/XI -> XI
! factorial/gamma, fact(X) gamma(X+1) -> X
% percentage, X/100*YJ -> XI
2ndF SHIFT
SHIFT does not operate
CLS clear entry
CA clear all, restart
SPACE (or SHIFT minus) change sign, -XI -> XI
ENTER push on stack
BS delete
LEFT delete
RIGHT swap XI with YJ
UP roll stack up
DOWN roll stack down
RCM last-x, push LM -> XI
S-CONST (SHIFT CONST) display registers (press key to continue)
CONST STO [+|-|*|/] #register (press digit, or op then digit)
ANS RCL [+|-|*|/] #register (press digit, or op then digit)
F<->E re<->im, swap X with I,
->DEG hh.mmss X -> degree X
->DMS degree X ->hh.mmss X
PI push pi -> X
RND random, push random 0<x<1 -> X
MDF round towards zero, round(XI) -> XI
STAT clear stat registers R2 to R7
M+ stat add Y,X (updates registers R2 to R7 as per HP-15C stat)
M- stat remove Y,X
= enter Basic expression
... any PC-G850 calculator function key such as SIN

The implementation attempts to avoid intermediate overflow and roundoff issues, e.g. Numerical Recipes and "What Every Computer Scientist Should Know About Floating-Point Arithmetic".

New and improved version: annotated with comments and without comments

To extend the program, for example to press Q to produce the quotient and remainder of Y/X, just add an entry for key Q (ASCII 81) line 181:

' Q quotient and remainder of Y/X -> X,Y (quotient in X, remainder in Y)
181 IF A=81 GOTO 1000

1000 IF I<>0 OR J<>0 OR X=0 OR X<>INT X OR Y<>INT Y OR ABS X>=1E10 OR ABS Y>=1E10 GOTO 15 ' error
1010 N=X,X=SGN X*INT(Y/ABS X),Y=Y-N*X: GOTO 40

Enjoy!

Thanks so much !!! I have just discovered this calc and I love it. It is even better now.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Sharp PC-G850VS - Zaphod - 04-16-2018, 08:49 AM
RE: Sharp PC-G850VS - grsbanks - 04-16-2018, 08:58 AM
RE: Sharp PC-G850VS - Zaphod - 04-16-2018, 10:26 AM
RE: Sharp PC-G850VS - andylithia - 04-16-2018, 12:26 PM
RE: Sharp PC-G850VS - mfleming - 04-16-2018, 02:16 PM
RE: Sharp PC-G850VS - Zaphod - 04-16-2018, 09:31 AM
RE: Sharp PC-G850VS - Helix - 04-16-2018, 02:33 PM
RE: Sharp PC-G850VS - mfleming - 04-16-2018, 06:39 PM
RE: Sharp PC-G850VS - Zaphod - 04-16-2018, 07:02 PM
RE: Sharp PC-G850VS - mfleming - 04-16-2018, 10:13 PM
RE: Sharp PC-G850VS - Zaphod - 04-23-2018, 09:57 PM
RE: Sharp PC-G850VS - mfleming - 04-24-2018, 03:37 AM
RE: Sharp PC-G850VS - Zaphod - 04-24-2018, 07:33 AM
RE: Sharp PC-G850VS - mfleming - 04-24-2018, 07:35 PM
RE: Sharp PC-G850VS - Zaphod - 04-24-2018, 07:54 PM
RE: Sharp PC-G850VS - Zaphod - 04-30-2018, 10:44 AM
RE: Sharp PC-G850VS - mfleming - 04-30-2018, 06:08 PM
RE: Sharp PC-G850VS - mfleming - 05-05-2018, 10:22 PM
RE: Sharp PC-G850VS - Zaphod - 05-02-2018, 10:48 AM
RE: Sharp PC-G850VS - mfleming - 05-02-2018, 03:46 PM
RE: Sharp PC-G850VS - Zaphod - 05-02-2018, 08:50 PM
RE: Sharp PC-G850VS - Helix - 05-02-2018, 10:44 PM
RE: Sharp PC-G850VS - Zaphod - 05-03-2018, 07:29 AM
RE: Sharp PC-G850VS - rprosperi - 05-03-2018, 12:56 PM
RE: Sharp PC-G850VS - Zaphod - 05-03-2018, 02:17 PM
RE: Sharp PC-G850VS - grsbanks - 05-03-2018, 02:19 PM
RE: Sharp PC-G850VS - Zaphod - 05-03-2018, 02:43 PM
RE: Sharp PC-G850VS - Zaphod - 05-03-2018, 04:14 PM
RE: Sharp PC-G850VS - Zaphod - 05-03-2018, 04:15 PM
RE: Sharp PC-G850VS - Zaphod - 05-03-2018, 04:17 PM
RE: Sharp PC-G850VS - Helix - 05-03-2018, 10:44 PM
RE: Sharp PC-G850VS - mfleming - 05-03-2018, 11:17 PM
RE: Sharp PC-G850VS - Helix - 05-04-2018, 12:49 AM
RE: Sharp PC-G850VS - rprosperi - 05-04-2018, 03:04 AM
RE: Sharp PC-G850VS - Zaphod - 05-04-2018, 05:31 AM
RE: Sharp PC-G850VS - Zaphod - 05-04-2018, 07:53 AM
RE: Sharp PC-G850VS - twdeckard - 05-06-2018, 08:18 PM
RE: Sharp PC-G850VS - mfleming - 05-06-2018, 08:49 PM
RE: Sharp PC-G850VS - jwhsu - 07-11-2018, 11:01 PM
RE: Sharp PC-G850VS - rprosperi - 07-11-2018, 11:17 PM
RE: Sharp PC-G850VS - foroplus - 07-12-2018, 09:17 AM
RE: Sharp PC-G850VS - toml_12953 - 08-19-2018, 12:53 AM
RE: Sharp PC-G850VS - smp - 08-19-2018, 01:28 AM
RE: Sharp PC-G850VS - toml_12953 - 08-20-2018, 03:23 AM
RE: Sharp PC-G850VS - Eddie W. Shore - 07-12-2018, 02:06 PM
RE: Sharp PC-G850VS - Helix - 07-12-2018, 02:44 PM
RE: Sharp PC-G850VS - jwhsu - 07-12-2018, 04:23 PM
RE: Sharp PC-G850VS - robve - 09-09-2020, 09:53 PM
RE: Sharp PC-G850VS - mfleming - 07-12-2018, 01:51 AM
RE: Sharp PC-G850VS - jwhsu - 07-18-2018, 02:08 PM
RE: Sharp PC-G850VS - rprosperi - 07-19-2018, 01:35 AM
RE: Sharp PC-G850VS - jwhsu - 07-19-2018, 03:13 AM
RE: Sharp PC-G850VS - rprosperi - 07-19-2018, 03:24 AM
RE: Sharp PC-G850VS - SlideRule - 07-19-2018, 04:07 PM
RE: Sharp PC-G850VS - Zaphod - 07-20-2018, 08:36 AM
RE: Sharp PC-G850VS - Jlouis - 07-25-2018, 10:29 PM
RE: Sharp PC-G850VS - rprosperi - 07-25-2018, 10:36 PM
RE: Sharp PC-G850VS - Helix - 07-26-2018, 10:40 AM
RE: Sharp PC-G850VS - mfleming - 08-01-2018, 12:49 AM
RE: Sharp PC-G850VS - jwhsu - 08-01-2018, 09:42 PM
RE: Sharp PC-G850VS - jwhsu - 08-01-2018, 09:56 PM
RE: Sharp PC-G850VS - mfleming - 08-03-2018, 05:58 PM
RE: Sharp PC-G850VS - Zaphod - 08-05-2018, 08:33 PM
RE: Sharp PC-G850VS - jwhsu - 08-06-2018, 04:10 PM
RE: Sharp PC-G850VS - Jlouis - 08-06-2018, 11:55 PM
RE: Sharp PC-G850VS - Zaphod - 08-07-2018, 06:43 PM
RE: Sharp PC-G850VS - smp - 08-11-2018, 04:20 PM
RE: Sharp PC-G850VS - smp - 08-17-2018, 08:27 PM
RE: Sharp PC-G850VS - smp - 08-18-2018, 08:58 PM
RE: Sharp PC-G850VS - jwhsu - 08-20-2018, 12:21 PM
RE: Sharp PC-G850VS - rprosperi - 08-20-2018, 12:38 PM
RE: Sharp PC-G850VS - jwhsu - 08-20-2018, 12:52 PM
RE: Sharp PC-G850VS - rprosperi - 08-20-2018, 02:55 PM
RE: Sharp PC-G850VS - smp - 08-20-2018, 08:37 PM
RE: Sharp PC-G850VS - megarat - 08-24-2018, 10:12 PM
RE: Sharp PC-G850VS - toml_12953 - 09-05-2018, 12:56 PM
RE: Sharp PC-G850VS - xerxes - 09-06-2018, 09:47 AM
Sharp PC-G850VS STAT Mode - toml_12953 - 09-13-2018, 03:57 AM
RE: Sharp PC-G850VS - mfleming - 09-13-2018, 02:33 PM
RE: Sharp PC-G850VS - Zaphod - 09-13-2018, 04:34 PM
RE: Sharp PC-G850VS - rprosperi - 09-13-2018, 05:12 PM
RE: Sharp PC-G850VS - mfleming - 09-13-2018, 07:23 PM
RE: Sharp PC-G850VS - Zaphod - 09-13-2018, 08:36 PM
RE: Sharp PC-G850VS - brickviking - 09-13-2018, 09:59 PM
RE: Sharp PC-G850VS - Zaphod - 09-13-2018, 10:03 PM
RE: Sharp PC-G850VS - foroplus - 09-15-2018, 08:42 AM
RE: Sharp PC-G850VS - rprosperi - 09-15-2018, 12:59 PM
RE: Sharp PC-G850VS - foroplus - 09-15-2018, 01:10 PM
RE: Sharp PC-G850VS - jwhsu - 09-18-2018, 01:07 AM
RE: Sharp PC-G850VS - foroplus - 09-18-2018, 09:55 AM
RE: Sharp PC-G850VS - toml_12953 - 09-14-2018, 12:09 AM
RE: Sharp PC-G850VS - Zaphod - 09-14-2018, 10:44 AM
RE: Sharp PC-G850VS - jwhsu - 09-14-2018, 04:22 PM
RE: Sharp PC-G850VS - Zaphod - 09-14-2018, 05:26 PM
RE: Sharp PC-G850VS - toml_12953 - 09-21-2018, 05:18 PM
RE: Sharp PC-G850VS - jwhsu - 09-22-2018, 02:00 AM
RE: Sharp PC-G850VS - toml_12953 - 09-22-2018, 02:03 AM
RE: Sharp PC-G850VS - Zaphod - 09-13-2018, 08:47 PM
RE: Sharp PC-G850VS - Zaphod - 09-13-2018, 09:14 PM
RE: Sharp PC-G850VS - jwhsu - 09-18-2018, 10:58 PM
RE: Sharp PC-G850VS - rprosperi - 09-18-2018, 11:35 PM
RE: Sharp PC-G850VS - jwhsu - 09-18-2018, 11:42 PM
RE: Sharp PC-G850VS - mfleming - 09-19-2018, 01:02 AM
RE: Sharp PC-G850VS - jwhsu - 09-19-2018, 02:14 AM
RE: Sharp PC-G850VS - Zaphod - 09-21-2018, 05:34 PM
RE: Sharp PC-G850VS - Zaphod - 09-22-2018, 06:48 PM
RE: Sharp PC-G850VS - megarat - 10-01-2018, 02:25 AM
RE: Sharp PC-G850VS - Zaphod - 10-01-2018, 12:19 PM
RE: Sharp PC-G850VS - xerxes - 10-01-2018, 12:52 PM
RE: Sharp PC-G850VS - Jlouis - 10-24-2018, 07:40 PM
RE: Sharp PC-G850VS - koikoi - 08-21-2019, 11:38 PM
RE: Sharp PC-G850VS - Jlouis - 09-01-2019, 11:16 AM
RE: Sharp PC-G850VS - koikoi - 09-06-2019, 12:58 PM
RE: Sharp PC-G850VS - david16965 - 12-23-2019, 12:52 PM
RE: Sharp PC-G850VS - david16965 - 12-23-2019, 04:21 PM
RE: Sharp PC-G850VS - Luca Puntin - 03-07-2020, 03:38 AM
RE: Sharp PC-G850VS - mfleming - 03-07-2020, 03:58 PM
RE: Sharp PC-G850VS - Luca Puntin - 03-08-2020, 09:13 AM
RE: Sharp PC-G850VS - mfleming - 03-09-2020, 02:07 AM
PC G850 PIC programming - Luca Puntin - 03-09-2020, 01:59 PM
RE: Sharp PC-G850VS - thenozone - 03-19-2020, 12:24 AM
RE: Sharp PC-G850VS - Luca Puntin - 03-19-2020, 09:31 PM
RE: Sharp PC-G850VS - robve - 10-03-2020, 03:20 PM
RE: Sharp PC-G850VS - robve - 11-06-2020, 08:27 PM
RE: Sharp PC-G850VS - grsbanks - 12-09-2020, 07:03 PM
RE: Sharp PC-G850VS - grsbanks - 12-15-2020, 04:05 PM
RE: Sharp PC-G850VS - twdeckard - 12-16-2020, 02:03 AM
RE: Sharp PC-G850VS - grsbanks - 12-16-2020, 07:17 AM
RE: Sharp PC-G850VS - tommi60 - 12-16-2020, 08:23 AM
RE: Sharp PC-G850VS - toml_12953 - 12-17-2020, 04:32 AM
RE: Sharp PC-G850VS - Dave Britten - 12-17-2020, 06:23 PM
RE: Sharp PC-G850VS - twdeckard - 12-17-2020, 10:17 PM
RE: Sharp PC-G850VS - robve - 12-18-2020, 07:48 PM
RE: Sharp PC-G850VS - groskwik - 06-11-2021 07:35 AM
RE: Sharp PC-G850VS - mfleming - 12-19-2020, 07:52 PM
RE: Sharp PC-G850VS - robve - 12-27-2020, 06:57 PM
RE: Sharp PC-G850VS - mfleming - 01-25-2021, 04:09 PM
RE: Sharp PC-G850VS - Eddie W. Shore - 02-22-2021, 12:26 AM
RE: Sharp PC-G850VS - robve - 02-22-2021, 02:17 AM
RE: Sharp PC-G850VS - robve - 02-22-2021, 09:28 PM
RE: Sharp PC-G850VS - rprosperi - 02-22-2021, 12:38 AM
RE: Sharp PC-G850VS - robve - 02-22-2021, 02:53 AM
RE: Sharp PC-G850VS - rprosperi - 02-22-2021, 10:29 PM
RE: Sharp PC-G850VS - robve - 02-23-2021, 04:03 AM
RE: Sharp PC-G850VS - silven - 06-03-2021, 05:30 PM
RE: Sharp PC-G850VS - robve - 06-06-2021, 07:45 PM
RE: Sharp PC-G850VS - silven - 06-07-2021, 05:00 PM
RE: Sharp PC-G850VS - robve - 06-07-2021, 09:30 PM
RE: Sharp PC-G850VS - silven - 06-16-2021, 11:26 PM
RE: Sharp PC-G850VS - Helix - 06-19-2021, 03:40 PM
RE: Sharp PC-G850VS - robve - 07-12-2021, 07:11 PM
RE: Sharp PC-G850VS - rprosperi - 06-08-2021, 12:37 PM
RE: Sharp PC-G850VS - robve - 06-08-2021, 05:18 PM
RE: Sharp PC-G850VS - rprosperi - 06-09-2021, 02:18 AM
RE: Sharp PC-G850VS - blackjetrock - 06-17-2021, 04:43 AM



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