# Roman numbers ↔ Latin alphabet counter

We can number lists using different counter styles, for example using Hindu–Arabic numerals and the decimal system 1, 2, 3, …, 9, 10, 11, … or using the Latin alphabet *A*, *B*, *C*, …, *Z*, *AA*, *AB*, … or using the Roman number system *I*, *II*, *III*, *IV*, *V*, *VI*, ….

When we ignore the values of these symbols for a moment and only look at the characters used, we see that the Roman numerals are a subset of the Latin alphabet. Furthermore the alphabet counter uses every possible combination of letters. Hence for every Roman number there is a number in the Latin alphabet counter that looks the same.

For example, the Roman numeral for one, *I*, also appears in the Latin alphabet counter where it represents the number nine, as it is the ninth letter in the alphabet. *V* is a Roman five and at the same time the twenty-second letter in the alphabet. *DC* is a Roman six hundred and at the same time one hundred and seven in the Latin alphabet counter.

I’ve compiled a table that lists all Roman numbers from one (*I*) to 3999 (*MMMCMXCIX*) and the corresponding values which the same representations have when interpreted as Latin alphabetic numbers:

## How do you do this?

There is no universally accepted standard of writing Roman numbers. For example, analog clock faces often display four as *IIII* instead of *IV* like I did above. So let’s settle on a convention first. I chose the one used for counter styles in cascading style sheets (CSS). It corresponds perfectly to what I learned at school about Roman numbers, although the explanation differs a little.

### Step 1

The CSS specification defines thirteen Roman symbols, each consisting of one or two letters, and their corresponding values displayed as decimal numbers here. When you want to write a natural number with Roman numerals, you start at the left side of the table, at the first symbol *M*.

symbol | M | CM | D | CD | C | XC | L | XL | X | IX | V | IV | I |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|

value | 1000 | 900 | 500 | 400 | 100 | 90 | 50 | 40 | 10 | 9 | 5 | 4 | 1 |

If your number is at least as big as the value of the current symbol, you write down the current symbol and reduce your number by the symbol’s value, otherwise you move right to the next symbol. Repeat this until your number is zero.

You’ll write done your initial number in terms of Roman numerals in the process. Easy, isn’t it? That’s the first step. The second step is to interpret that string of symbols as a Latin alphabetic representation and compute its value.

### Step 2

The alphabetic number system is a positional system like our decimal system, but without a number zero. The letters *A* to *Z* are its digits and correspond to the values 1 to 26. You will only need a small subset of these when reinterpreting Roman numbers:

digit | C | D | I | L | M | V | X |
---|---|---|---|---|---|---|---|

value | 3 | 4 | 9 | 12 | 13 | 22 | 24 |

You compute the value of an alphabetic number by multiplying each digit’s value with the positional value of its place in the number and adding these products up. The positional value of the rightmost place is 26^{0} = 1, the value of the second place from right is 26^{1} = 26, the value of the third place from right is 26^{2} = 676. In general, the value of the n-th place from right is 26^{n−1}.

### Example: 54

Confused? An example will help. Let’s find the Roman number representation of fifty-four.

Look at table 2 and find the leftmost symbol whose value is equal to or lower than our number fifty-four. That would be *L*. Write down *L* and reduce our number by the value of *L*, fifty. That leaves us four. Now find the leftmost symbol whose value is equal to or lower than our number four. That is *IV*. Write down *IV* and reduce our number by the value of *IV*, which is four. That leaves us zero, so we are done with the first step. You have written down *LIV* and that’s indeed how Romans would write fifty-four:

*LIV*

Now reimagine *LIV* as a Latin alphabetic number representation. To compute its value, start at its right side with the digit *V*. The digit value of *V* is 22 according to table 3. Multiply that with the positional value of the rightmost place, 26^{0}.

22 ⋅ 26^{0} = 22

Now move one place left to *I*, raising the positional value to 26^{1}. The digit value of *I* is 9. Multiply those values:

9 ⋅ 26^{1} = 234

The positional value increases to 26^{2} when you move another place to the left, where we find *L*, which has a digit value of 12. The corresponding product is

12 ⋅ 26^{2} = 8112

Finally add 22 + 234 + 8112 and that’s the value of *LIV* when interpreted as Latin alphabetic number:

8368