Post Reply 
Dismal Arithmetic & 3 Progs for 49G & Others
05-08-2015, 02:53 PM
Post: #20
RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S
(At least) one more: Casio fx-8500G. 435,821 * 2,949,229 takes 16 seconds, but seems to overflow the precision of the machine. I get 244,585,835,800 instead of 244,585,835,821.

Code:
Prog 3 - Number Length
Ans=0=>Goto 9
Int log Ans+1
Lbl 9

Prog 4 - Get Digit
Frac (Int (N/10^(D-1))/10)*10

Prog 5 - Add
G=1=>Goto 0
"X"?->A
"Y"?->B
Lbl 0
0->G
A
Prog 3
Ans->C
B
Prog 3
Ans>C=>Ans->C
1->I
0->S
Lbl 1
A->N
I->D
Prog 4
Ans->T
B->N
Prog 4
Ans>T=>Ans->
T*10^(I-1)+S->S
I+I->I
I<=C=>Goto 1
S

Prog 6 - Multiply
"X"?->X
"Y"?->Y
X
Prog 3
Ans->Z
Y
Prog 3
Ans->J
0->F
Lbl 1
Y->N
J->D
Prog 4
Ans->M
1->K
0->P
Lbl 2
M->U
X->N
K->D
Prog 4
Ans<U=>Ans->U
U*10^(K-1)+P->P
1+K->K
K<=Z=>Goto 2
P->A
F*10->B
1->G
Prog 5
Ans->F
Dsz J:Goto 1
F


Variables
G - "Don't Prompt" flag (interactive vs. called by multiplication program)
A - Addend 1
B - Addend 2
C - Add loop limit (addend max length)
I - Add loop counter
S - Sum
T - Addition scratch register (digit comparison)

X - Factor 1
Y - Factor 2
Z - Factor 1 length
J - Factor 2 length/outer loop counter
K - Inner loop counter (factor 1)
P - Product
F - Sum of products
M - Factor 2 current digit
U - Multiply scratch register (digit comparison)

N - Input number
D - Input digit
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Dave Britten - 05-08-2015 02:53 PM



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