HP Forums
HP 42S: Programming Complexity Question - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 42S: Programming Complexity Question (/thread-5590.html)



HP 42S: Programming Complexity Question - Gerald H - 01-25-2016 05:26 PM

Is it really more difficult to convert Arabic numbers to Roman than Roman to Arabic?

Here a 42S programme for A2R

http://www.hpmuseum.org/forum/thread-5583.html

size is 162 Bytes & here for R2A

http://www.hpmuseum.org/forum/thread-1640.html?highlight=roman

size 78 Bytes.

Is it my poor programming or is the inverse problem really so much more difficult?


RE: HP 42S: Programming Complexity Question - TASP - 01-25-2016 11:03 PM

"Back in the day" it was noted the longer calendar printing programs (HP41 series) tended to print calendars faster then the shorter programs.

I've tried to not let anything about programming amaze me since.

Wink


RE: HP 42S: Programming Complexity Question - emece67 - 01-26-2016 07:25 AM

(01-25-2016 08:01 PM)Mike (Stgt) Wrote:  Example: compare the Euclidian algorithm on an AOS system vs one on a UPN machine.

Excuse my ignorance but, what are AOS systems & UPN machines?


RE: HP 42S: Programming Complexity Question - walter b - 01-26-2016 07:37 AM

(01-26-2016 07:25 AM)emece67 Wrote:  ... what are AOS systems & UPN machines?

AOS = Algebraic Operating System
UPN = RPN in German

d:-)


RE: HP 42S: Programming Complexity Question - renif - 01-26-2016 12:15 PM

"Is it really more difficult to convert Arabic numbers to Roman than Roman to Arabic?"

Well, that definitely is a question relating to the mathematical structure of the problem. IMHO the size comparison between the two codes for the HP-42s at least gives a hint. It seems to be similar on other machines and in other languages, but this difference becomes especially apparent with implementations in an environment with very restricted memory, where the conversion Roman to Arabic can be realized, but not the opposite. In my old collection of programs, e.g. I found one for the TI-57 (max. 50 program steps) converting from Roman to Arabic (or better: Hindu numeral system). Never saw a program for the TI-57 converting from Hindu to Roman numerals. But that's only another hint, not a real proof, that the one algorithm is more difficult than the other.


RE: HP 42S: Programming Complexity Question - Gerald H - 01-26-2016 01:42 PM

Here a smaller A2R programme which produces valid Roman numerals BUT only produces forms such as MIIII for 1004 & not MIV:

Code:

00 { 101-Byte Prgm }
01>LBL "A2R"
02 CLA
03 1.007
04 RCL ST Y
05>LBL 00
06>LBL 14
07 XEQ IND ST Y
08 X>Y?
09 GTO 15
10 -
11 GTO 14
12>LBL 15
13 Rv
14 ISG ST Y
15 GTO 00
16 RCL ST Z
17 AVIEW
18 RTN
19>LBL 01
20 1E3
21 X<=Y?
22 |-"M"
23 RTN
24>LBL 02
25 500
26 X<=Y?
27 |-"D"
28 RTN
29>LBL 03
30 100
31 X<=Y?
32 |-"C"
33 RTN
34>LBL 04
35 50
36 X<=Y?
37 |-"L"
38 RTN
39>LBL 05
40 10
41 X<=Y?
42 |-"X"
43 RTN
44>LBL 06
45 5
46 X<=Y?
47 |-"V"
48 RTN
49>LBL 07
50 1
51 X<=Y?
52 |-"I"
53 .END.



RE: HP 42S: Programming Complexity Question - emece67 - 01-26-2016 04:28 PM

(01-26-2016 07:37 AM)walter b Wrote:  
(01-26-2016 07:25 AM)emece67 Wrote:  ... what are AOS systems & UPN machines?

AOS = Algebraic Operating System
UPN = RPN in German

d:-)

Thanks,