How Roman Numerals Work
Roman numerals use combinations of the letters I, V, X, L, C, D, and M to represent numbers. The system is based on additive and subtractive principles.
Basic Roman Numeral Values
I = 1 V = 5
X = 10 L = 50
C = 100 D = 500
M = 1000
Subtractive Notation (Important Rule)
When a smaller numeral appears before a larger one, it is subtracted:
- IV = 4 (5 - 1)
- IX = 9 (10 - 1)
- XL = 40 (50 - 10)
- XC = 90 (100 - 10)
- CD = 400 (500 - 100)
- CM = 900 (1000 - 100)
Calculation Process
- Number to Roman: The calculator uses a greedy algorithm, always choosing the largest possible Roman numeral value that does not exceed the remaining number.
- Roman to Number: It iterates through the string. If the current numeral is smaller than the next one, it subtracts its value; otherwise, it adds it.
Limitations
- This converter supports numbers from 1 to 3999 (standard Roman numerals do not have a symbol for 5000 or higher in the classical system).
- Only valid Roman numerals are accepted in the reverse conversion.