Roman Numeral Converter Formula

Understand the math behind the roman numeral converter. Each variable explained with a worked example.

Formulas Used

Thousands Digit

thousands = floor(num / 1000)

Hundreds Digit

hundreds = floor(mod(num, 1000) / 100)

Tens Digit

tens = floor(mod(num, 100) / 10)

Ones Digit

ones = mod(num, 10)

Variables

VariableDescriptionDefault
numNumber (1-3999)2024

How It Works

Roman Numeral Conversion

Roman Numeral Symbols

| Symbol | Value | |--------|-------| | I | 1 | | V | 5 | | X | 10 | | L | 50 | | C | 100 | | D | 500 | | M | 1000 |

Rules

1. Symbols are generally written from largest to smallest, left to right 2. If a smaller symbol appears before a larger one, subtract it (e.g., IV = 4, IX = 9) 3. The same symbol can be repeated up to 3 times in a row

Example: 2024 = MMXXIV

  • 2000 = MM
  • 20 = XX
  • 4 = IV
  • Worked Example

    Convert 2024 to Roman numerals.

    num = 2024
    1. 01Thousands: floor(2024/1000) = 2 → MM
    2. 02Hundreds: floor(24/100) = 0 → (none)
    3. 03Tens: floor(24/10) = 2 → XX
    4. 04Ones: 4 → IV
    5. 05Result: MMXXIV

    Ready to run the numbers?

    Open Roman Numeral Converter