Roman numerals are a numerical system that originated in ancient Rome. They are used to represent numbers in the decimal system, but they are not used for mathematical operations.
In this system, symbols are used to represent different numbers, with I representing 1, V representing 5, X representing 10, L representing 50, C representing 100, D representing 500, and M representing 1,000.
Here is a table of the symbols used in the Roman numeral system:
The value of a numeral is determined by its position in relation to other symbols. When a symbol of equal or lesser value is placed after another symbol, their values are added. But when certain symbols of lesser value are placed before another symbol, their values are subtracted.
For example, the numeral VI, or 6, would be read as "five plus one" (5 + 1), and XI, or 11, is "ten plus one" (10 + 1).
But the methods for representing 4 and 9 are special. The Roman numeral IV, or 4, would be read as "one less than 5" (5 - 1). Also, the numeral IX, or 9, would be read as "one less than 10" (10 - 1).
Here is a table of numbers and their Roman numeral equivalent, followed by more in-depth explanations about how to perform the conversions. Just scroll through the table or use Ctrl/Cmd + f to find the value you're looking for:
How to Convert a Number into Roman Numerals
Because Roman numerals are often ordered from largest to smallest, break the number you're converting up into groups of thousands, hundreds, tens, and ones, and perform the conversion on each group.
For example, if you want to convert the number 2,014 (the year freeCodeCamp was founded) into Roman numerals, break the number up as follows:
2,014 = 2,000 + 10 + 4
Then perform the conversion on each group and combine them to get the Roman numeral equivalent:
* 2,000 = MM * 10 = X * 4 = IV 2,014 = 2,000 + 10 + 4 = MMXIV
How to Represent Large Numbers in Roman Numerals
You might have noticed that the chart above only goes from 1 to 3,999.
This is due to the special methods for representing 4 and 9 mentioned above. If you check the table above, you'll see that whenever a 4 or 9 appears (including 40, 90, 400, 900) that the Roman numerals are ordered in a particular way so the lesser symbol is subtracted from the one of greater value immediate afterwards.
Since Roman numerals were never fully standardized, you might see the number 4,000 represented as MMMM.
This works, but many see this as invalid since 4 (and 9) have special representations in lower numbers.
Instead, one of the most common ways to represent larger Roman numerals is with a vinculum, or a straight horizontal line above one or more symbols.
If you see a Roman numeral symbol with a horizontal line over it, that just means to multiply that symbol by 1,000.
Here are the Roman numeral symbols with the vinculum applied:
|M or I||V||X||L||C||D||M|
With this extended set of Roman numeral symbols, 4,000 would be represented as the following:
And here's a table of larger numbers and their Roman numeral representations to get you started:
How to Add a Vinculum or Horizontal Line Over Roman Numerals With HTML and CSS
For you devs out there, the easiest way to add a vinculum to Roman numerals online is to wrap the symbols in an element and use a bit of CSS.
For example, to add a horizontal line over the symbols IV in IVIII, you can wrap them in a
span element and set its
text-decoration property to
<p><span style="text-decoration: overline;">IV</span>III</p>
Which will render the following:
Thanks for Reading
If you found this breakdown of Roman numerals helpful, please share it with your friends so more people can benefit from it.
Also, feel free to reach out on Twitter and let me know what you think.