How Does Roman Numeral Converter Work?
The converter uses a greedy algorithm over 13 value-symbol pairs: 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). For number-to-Roman, it subtracts the largest fitting value and appends the symbol, repeating until zero. For Roman-to-number, it reads left to right — when a symbol is smaller than the next one, it is subtracted; otherwise added. This matches the encoding described in the Wikipedia article on Roman numerals. In our testing, all 13 subtractive pairs work correctly, including MCMXCIX (1,999) and MMCMXCIX (2,999), tested across thousands of conversions in both directions.