Understanding the Roman numeral converter — concept and principle
Roman numerals write numbers with seven letters: I = 1, V = 5, X = 10, L = 50, C = 100, D = 500 and M = 1000. They are still used for years on buildings and film credits, clock faces, monarchs and popes (Elizabeth II), book chapters, outlines and events such as the Super Bowl. This converter works both ways: type a whole number from 1 to 3999 to get the numeral, or type a numeral to get its value.
How it is calculated
The converter uses standard subtractive notation with thirteen building blocks, from largest to smallest: M 1000, CM 900, D 500, CD 400, C 100, XC 90, L 50, XL 40, X 10, IX 9, V 5, IV 4, I 1.
- Number → numeral: repeatedly take the largest block that still fits, write its letters and subtract its value, until nothing is left.
- Numeral → number: read the text from left to right, matching the same blocks in the same order, and add up their values. Letters must be I, V, X, L, C, D or M; case does not matter.
The principle
Roman numerals are additive: letters are written from largest to smallest and their values are summed, so XXVI = 10 + 10 + 5 + 1. To avoid writing four identical letters in a row, a smaller letter placed before a larger one is subtracted. Only six such pairs are standard: IV (4), IX (9), XL (40), XC (90), CD (400) and CM (900). In effect each decimal digit is written separately: thousands with M, hundreds with C, D, M, tens with X, L, C and units with I, V, X. That is why the greedy method always gives the shortest standard form. Because there is no letter for 5000 in the basic system and no zero, the standard range is 1 to 3999.
Worked example
- Input: 2026.
- 2026 ≥ 1000, so write M (1026 left), then M again (26 left).
- 26 ≥ 10, so write X (16 left), then X (6 left).
- 6 ≥ 5, so write V (1 left); then 1 gives I.
- Result: MMXXVI = 1000 + 1000 + 10 + 10 + 5 + 1.
How to read the result
Split a numeral into its digit groups to read it quickly: MCMXCIV is M | CM | XC | IV = 1000 + 900 + 90 + 4 = 1994. A symbol is never repeated more than three times in standard form, and V, L and D are never repeated or subtracted.
Common mistakes
- Writing 99 as IC or 1990 as MXM. Subtraction only works within one digit: 99 = XCIX, 1990 = MCMXC.
- Writing 4 as IIII. It appears on many clock faces by tradition, but the standard form is IV.
- Expecting the converter to handle zero, fractions or numbers above 3999.
Frequently asked questions
How do you write 0 in Roman numerals?
There is no Roman numeral for zero. Medieval writers sometimes used the word nulla or the letter N.
How were numbers above 3999 written?
A bar over a numeral (vinculum) multiplied it by 1000, so V with a bar meant 5000. It is not part of the standard 1 to 3999 range.
What year is MCMLXXXV?
M (1000) + CM (900) + L (50) + XXX (30) + V (5) = 1985.
Sources: Encyclopaedia Britannica, "Roman numeral" · D. E. Smith, History of Mathematics, Vol. II, Ginn and Company (Dover reprint)