Re: WP 34S accuracy is excellent Message #15 Posted by C.Ret on 3 June 2012, 5:31 a.m., in response to message #14 by Paul Dale
Good news, I have here two new capable calculators, one SHARP PC-1211 Pocket Computer and one Hewlett Packard HP-41C Handled Calculator that confirm your full digit computation of 73^55.
So we have to add both on Jeff's 'capable calculator list' where already sat HP-50g, TI-89/92 and HP-28C/S.
HP-41C Program Listing:
@@~~ Initiate computation :
001 LBL "POWMOD"
STO 21 RCL Z x>y? x<>y @ keep MAX(F,M)
RDN ABS LOG INT 8 x<>y x>y? STOP @ stop on error condition MAX(F,M) too large
- 10^X STO 22 @ store EE in R(22)
RDN INT STO 23 @ store P in R(23)
@@~~ Print F ^ P = : \ "~ is the alpha 'append' caracter \
020 CLA FIX 0 ARCL Y "~^" ARCL X "~ = " PRA
@@~~ Initiale storage area R(0 to 19), set R(0) to 1, set pointer R(20)
027 Clx STO 20 1 STO 00 RDN RDN INT
@@~~ Outer loop : storage area multiplication
034 LBL 01 @ Reset storage area pointer
RCl 20 FRC STO 20
038 Clx @ Clear carry
@@~~ Inner loop : process each storage register
039 LBL 02
RCL IND 20 RCL Z * + RCL X RCL 22
MOD STO IND 20 @ store R(R(20)) digits without carry
- RCL 22 / INT @ store carry in stack
ISG 20 GTO 02 @ loop for each storage register
x=0? GTO 03
056 STO IND 20 .001 ST+ 20 @ if carry after last storage register
@ expand storage register area
@@~~ Repeat outer loop up to M multiplications
059 LBL 03
R^ DSE 23 GTO 01 @ loop P = R(23) times
063 RCL 21 @ Recall M
@@~~ Initiate MOD loop pointer R(23) from final R(20) value
064 LBL 04
RCL 20 1 - INT CHS STO 23 @ R(23) is now MOD loop counter
071 Clx @ Clear carry
@@~~ MOD computation loop
072 LBL 05
RCL 22 * RCL IND 23 PRX @ Print all digits of F^M
+ RCL Y MOD @ add carry , compute MOD
080 ISG 23 GTO 05 @ loop for each storage register (in reverse order)
@@~~ end of MOD loop
082 "MOD " ARCL Y "~ = " PRA @ Print/display "MOD M ="
086 PRX @ Print/display result
087 FIX 3
088 STOP @ End Of Program, wait for a new module entry
089 GTO 04
Registers :
R(0) - R(19) Full Digits Storage Area of F^P
R(20) Storage Pointer I.nnn
R(21) Store M value
R(22) Exponant Extand (EE) , base of digits storage area, all digits storage register less than EE or carry is reported to next storage postion.
R(23) Power loop counter 0 <- M / Mod loop Counter R(20)->0
Usage:
73 [ENTER^] 55 [ENTER^] 31 [XEQ][ALPHA]POWMOD[ALPHA]
Since full digits store in registers, any further modulo computation of the same F^P can be immediately achieve by entering M value and pressing [R/S].
Computation on a new F^P value need reseting computation by keystrokes: F [ENTER] M [ENTER^] M [ENTER^] [shift][RTN][R/S]
Listing obtained on Infrared Printer HP 82240A through IR module.
BASIC program lsting :
10:CLEAR :USING :INPUT "MOD(F^P,M): ENTER F,P,M ?";A,B,C
20:LET E=10^(8-INT LOG ABS C),I=1
30:FOR F=1 TO B:FOR G=9 TO 9+D
40: LET A(G)=H+A*A(G),H=0:IF A(G)>E LET H=INT (A(G)/E),A(G)=A(G)-E*H
50:NEXT G:IF H>0 LET D=D+1,A(9+D)=H,H=0
60:PAUSE F,D:NEXT F
70:PRINT A;"^";B;"=":FOR G=9+D TO 9 STEP -1:PRINT A(G)
80: LET H=E*H+A(G),F=INT (H/C),H=H-F*C
90:NEXT G:BEEP 1:PRINT "MOD ";C;" = ";H:END
Usage (in DEF or RUN mode):
> RUN[ENTER]
MOD(F^P,M) F,P,M ? 73[ENTER]
? 55[ENTER]
? 31[ENTER]
>
Listing obtained on SHARP Printer & Casette Interface CE-122.
Both algorthims use the same tactis as HP28C/S's LPOWMOD code:
Edited: 3 June 2012, 6:19 a.m.
|