The Museum of HP Calculators


Roman Numerals for the HP-41

This program is Copyright © 2004 by Jean-Marc Baillard and is used here by permission.

This program is supplied without representation or warranty of any kind. Jean-Marc Baillard and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

-Roman numerals use the following equivalences:                       M = 1000 ; D = 500 ; C = 100 ; L = 50 ; X = 10 ; V = 5 ; I = 1
-These letters are sorted in decreasing order
 and the numerical values are added, for instance:                       MCCXV = 1000 + 100 + 100 + 10 + 5 = 1215
-However, if a smaller numeral appears before a larger one,
  it must be subtracted instead of added, for example:                 XC = -10 + 100 = 90   ;    MCMXLIV =  1000 - 100 + 1000 - 10 + 50 - 1 + 5 = 1944
-These rules are used in the following conversion programs.
 

1°) Arabic Numerals  >>>  Roman Numerals
 

Data Registers: /
Flags: /
Subroutines: /
 

01  LBL "A-R"
02  " "                         ( one space )
03  LBL 01
04   E3
05  X>Y?
06  GTO 00
07  -
08  "~M"                    ( append M )
09  GTO 01
10  LBL 00
11  CLX
12  900
13  X<=Y?
14  "~CM"                 ( append CM )
15  X>Y?
16  CLX
17  -
18  500
19  X<=Y?
20  "~D"                     ( append D )
21  X>Y?
22  CLX
23  -
24  400
25  X<=Y?
26  "~CD"                  ( append CD )
27  X>Y?
28  CLX
29  -
30  LBL 02
31   E2
32  X>Y?
33  GTO 00
34  -
35  "~C"                     ( append C )
36  GTO 02
37  LBL 00
38  CLX
39  90
40  X<=Y?
41  "~XC"                  ( append XC )
42  X>Y?
43  CLX
44  -
45  50
46  X<=Y?
47  "~L"                     ( append L )
48  X>Y?
49  CLX
50  -
51  40
52  X<=Y?
53  "~XL"                  ( append XL )
54  X>Y?
55  CLX
56  -
57  LBL 03
58  10
59  X>Y?
60  GTO 00
61  -
62  "~X"                    ( append X )
63  GTO 03
64  LBL 00
65  DSE X
66  X<=Y?
67  "~IX"                   ( append IX )
68  X>Y?
69  CLX
70  -
71  5
72  X<=Y?
73  "~V"                    ( append V )
74  X>Y?
75  CLX
76  -
77  4
78  X<=Y?
79  "~IV"                   ( append IV )
80  X>Y?
81  CLX
82  -
83  LBL 04
84  1
85  X>Y?
86  GTO 00
87  -
88  "~I"                      ( append I )
89  GTO 04
90  LBL 00
91  AVIEW
92  END

( 154 bytes / SIZE 000 )
 
 

Examples:      1444   XEQ "A-R"  >>>>   MCDXLIV                            ( in 3 seconds )
                       4888         R/S         >>>>   MMMMDCCCLXXXVIII    ( in 9 seconds )
                       2345         R/S         >>>>   MMCCCXLV                       ( in 4 seconds )
 

-The result is in the alpha register.
 

2°) Roman Numerals  >>>  Arabic Numerals    ( X-Functions Module required )
 

Data Registers: /
Flags: /
Subroutines: /
 

01  LBL "R-A"
02  CLST
03  *
04  LBL 01
05  ATOX
06  X=0?
07  GTO 09
08  77
09  X=Y?
10  GTO 02
11  DSE X
12  X=Y?
13  GTO 03
14  CLX
15  68
16  X=Y?
17  GTO 04
18  DSE X
19  X=Y?
20  GTO 05
21  CLX
22  88
23  X=Y?
24  GTO 06
25  CLX
26  86
27  X=Y?
28  GTO 07
29  CLX
30  73
31  X#Y?
32  CLX
33  X#0?
34  SIGN
35  ENTER^
36  GTO 08
37  LBL 02
38   E3
39  GTO 08
40  LBL 03
41  50
42  GTO 08
43  LBL 04
44  500
45  GTO 08
46  LBL 05
47   E2
48  GTO 08
49  LBL 06
50  10
51  GTO 08
52  LBL 07
53  5
54  LBL 08
55  R^
56  X<>Y
57  LASTX
58  X<Y?
59  X<0?
60  CLX
61  ST+ X
62  ST- Z
63  RDN
64  +
65  GTO 01
66  LBL 09
67  X<>Y
68  END

( 106 bytes / SIZE 000 )
 

Examples:    [ alpha ]   MMMMDCCCLXXXVIII   [ alpha ]   XEQ "R-A"  >>>>  4888   ( in 16 seconds )
                     [ alpha ]   MCDXLIV  [ alpha ]                                    R/S       >>>>  1444   ( in 7 seconds )
                     [ alpha ]   MMCCCXLV  [ alpha ]                               R/S       >>>>  2345   ( in 8 seconds )
 

-If the alpha string contains other symbols, they will be neglected ( = zero )
-When the program stops, the alpha register is cleared.
 
 

Go back to the HP-41 software library
Go back to the general software library
Go back to the main exhibit hall