What Are Roman Numerals?
Roman numerals are the numeral system of the Roman Empire, still around today in a slightly tidied-up form: clock faces, the preface pages of a book, sequel titles like Rocky IV, the Super Bowl, and the copyright year buried in a film's closing credits. Seven letters carry all the weight:
| Symbol | I | V | X | L | C | D | M |
|---|---|---|---|---|---|---|---|
| Value | 1 | 5 | 10 | 50 | 100 | 500 | 1000 |
Two rules turn these seven letters into every whole number from 1 to 3999. Symbols are normally added left to right in decreasing order (VI is 5 plus 1, six), but writing a smaller value directly in front of a larger one means subtract instead (IV is 5 minus 1, four). Only I, X, and C are ever used this way, and only in front of the next two symbols above them on the scale - I before V or X, X before L or C, C before D or M. That restriction is exactly why 49 is written XLIX and never IL.
How the Conversion Works
Turning a number into a numeral works from a fixed list of value/symbol pairs, ordered from 1000 down to 1 and including the six subtractive pairs CM, CD, XC, XL, IX, and IV alongside the seven base symbols. Starting from the largest pair, the algorithm repeatedly appends the symbol and subtracts its value from the remaining number for as long as it still fits, then moves on to the next smaller pair. Because a subtractive pair always sits right before the base symbol it competes with - CM before D, CD before C, and so on - the result is always the shortest, canonical Roman numeral for any number from 1 to 3999. The converter stops at 3999 because larger values require an additional notation convention. One historical convention places a horizontal bar (a vinculum) over a numeral to multiply it by 1000.
The reverse direction, numeral to number, only needs to look at each symbol and its immediate successor. Reading left to right, a symbol is subtracted whenever the next symbol outranks it, and added otherwise:
\[ \sum_{i=1}^{n} \begin{cases} -V(s_i) & \text{if } V(s_i) < V(s_{i+1}) \\ V(s_i) & \text{otherwise} \end{cases} \]
with \(V(s_{n+1}) = 0\) by convention for the last symbol in the string. That single pass is enough to read IV as \(5-1=4\) and MCMXCIV as \(1000+(1000-100)+(100-10)+(5-1)=1994\), without ever needing to know where one "numeral" ends and the next begins.
A Few Worked Examples
| Number | Roman |
|---|---|
| 4 | IV |
| 9 | IX |
| 40 | XL |
| 90 | XC |
| 400 | CD |
| 900 | CM |
| 1994 | MCMXCIV |
| 2024 | MMXXIV |
| 3999 | MMMCMXCIX |