(42S) Roman to Arabic Representation - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (42S) Roman to Arabic Representation (/thread-1640.html) |
(42S) Roman to Arabic Representation - Gerald H - 06-16-2014 12:00 PM Given a valid Roman number in the alpha register the prog returns the value in Arabic form in the X register. 0. { 78-Byte Prgm } 1. LBL “R→A” 2. CLST 3. ALENG 4. X<> ST Z 5. LBL 09 6. ATOX 7. XTOA 8. R↓ 9. XEQ IND ST T 10. X<>Y 11. X<Y? 12. +/- 13. STO+ ST Z 14. R↓ 15. DSE ST Z 16. GTO 09 17. GTO 00 18. LBL 77 19. 1000 20. RTN 21. LBL 68 22. 500 23. RTN 24. LBL 67 25. 100 26. RTN 27. LBL 76 28. 50 29. RTN 30. LBL 88 31. 10 32. RTN 33. LBL 86 34. 5 35. RTN 36. LBL 73 37. 1 38. RTN 39. LBL 00 40. + 41. END Improvements welcome. RE: HP 42S Roman to Arabic Representation - HP67 - 06-16-2014 12:19 PM All I need now is a 42S in mint condition to check your work RE: HP 42S Roman to Arabic Representation - Massimo Gnerucci - 06-16-2014 12:27 PM (06-16-2014 12:19 PM)HP67 Wrote: All I need now is a 42S in mint condition to check your work Why mint and why not this? RE: HP 42S Roman to Arabic Representation - HP67 - 06-16-2014 12:37 PM (06-16-2014 12:27 PM)Massimo Gnerucci Wrote:(06-16-2014 12:19 PM)HP67 Wrote: All I need now is a 42S in mint condition to check your work Because the build quality, great keyboard, and pride of ownership just aren't there for me RE: HP 42S Roman to Arabic Representation - Massimo Gnerucci - 06-16-2014 12:53 PM (06-16-2014 12:37 PM)HP67 Wrote:(06-16-2014 12:27 PM)Massimo Gnerucci Wrote: Why mint and why not this? Oh, almost forgot those sensations... This evening I'll handle my mint one then. Or one of the others. RE: HP 42S Roman to Arabic Representation - rprosperi - 06-16-2014 01:02 PM (06-16-2014 12:53 PM)Massimo Gnerucci Wrote: This evening I'll handle my mint one then. Or one of the others. What a guy!! RE: HP 42S Roman to Arabic Representation - Massimo Gnerucci - 06-16-2014 01:06 PM (06-16-2014 01:02 PM)rprosperi Wrote:(06-16-2014 12:53 PM)Massimo Gnerucci Wrote: This evening I'll handle my mint one then. Or one of the others. Sorry if I sounded a little braggart. Eheheheh... RE: HP 42S Roman to Arabic Representation - Gerald H - 06-16-2014 01:22 PM To posts #2 to #7: The sensual nature of the HP 42S is undeniable but not a propos the topic. Perhaps start a new thread on sensuality grading of various models? RE: (42S) Roman to Arabic Representation - Danny - 05-13-2020 08:57 PM Nicely done, it works very well ! RE: (42S) Roman to Arabic Representation - Werner - 05-14-2020 08:56 AM Making use of a 13x2 matrix "RN": [[ 1000 77 ] [ 900 "CM" ] [ 500 68 ] [ 400 "CD" ] [ 100 67 ] [ 90 "XC" ] [ 50 76 ] [ 40 "XL" ] [ 10 88 ] [ 9 "IX" ] [ 5 86 ] [ 4 "IV" ] [ 1 73 ]] Both encodings can be written as follows: Code: 00 { 82-Byte Prgm } The →ROM routine appends the Roman numerals to the Alpha register; just add a CLA at the beginning and an AVIEW at the end if you want to see single results. The →ARB routine (a copy of yours, Gerald, but using the RN matrix instead) has a rudimentary error check: when it encounters an unknown character it produces an "Alpha Data is Invalid" message. Cheers, Werner RE: (42S) Roman to Arabic Representation - Gerald H - 05-16-2020 10:19 AM Werner - How do you put alpha data in a matrix? RE: (42S) Roman to Arabic Representation - Werner - 05-16-2020 02:18 PM with ASTO ST X while editing. or run the following program to create the matrix: Code: 00 { 164-Byte Prgm } Cheers, Werner RE: (42S) Roman to Arabic Representation - Gerald H - 05-17-2020 07:07 AM Thank you, Werner, for the advice on entering alpha data into a matrix, I couldn't find this explicitly in the manual, do you have a reference? I had for some time (6 years?) thought there should be an equally economical algorithm for ->ROM as for ->ARB but never found/invented one, so your programme is much appreciated. The matrix RN occupies 230 Bytes of memory, so total for programme & matrix is 312 Bytes. The programme below is my previous best attempt & is a little faster than yours. Code: 0. { 245-Byte Prgm } RE: (42S) Roman to Arabic Representation - Werner - 05-17-2020 08:11 AM Hi Gerald, no I don't have a reference, I just tried it once and it worked ;-) And the >ROM algorithm is not mine.. I just made it matrix-based. Roman Numerals for the 41 And that looks eerily like yours -) Cheers, Werner RE: (42S) Roman to Arabic Representation - Gerald H - 05-17-2020 08:58 AM 2020-05-2020 15:54 Vienna time Edit: the original posting Yes, I'm fairly sure I copied Jean-Marc Baillard's programme in the first place, all credit to him. is incorrect. In fact it's a copy of Didier Lachieze' programme as referenced here: https://www.hpmuseum.org/forum/thread-5583.html?highlight=arabic RE: (42S) Roman to Arabic Representation - Gerald H - 05-17-2020 09:12 AM The handbook "HP-42S RPN Scientific Programming Examples and Techniques" exemplifies storing alpha data in a matrix on page 147. |