This uses the standard modern Roman numeral rules (subtractive notation).

Decimal → Roman
—
Roman → Decimal
—