Roman Numeral Converter

Numbers to numerals and back, both ways.

Numbers to numerals and back, both ways.

How to use it

  1. Type either one. A number or a numeral. The direction is worked out from what you typed.
  2. Read the answer. Numerals come back in upper case, which is the only way they are written.
  3. Copy it. Nothing is stored and nothing was sent anywhere.

When you would use this

Roman numerals look like a lookup table and are mostly a set of rules about what you are not allowed to write. The subtractive pairs are the first one. Four is IV rather than IIII, forty is XL, nine hundred is CM. An implementation that omits them produces numerals that are readable and wrong, which is the standard bug in this conversion. The second is that many strings parse to a number without being valid numerals. IIII reads as four and IC reads as ninety nine, and neither is written by anyone. The only reliable way to check is to convert the answer back and compare, which is what happens here: if the round trip does not match, the input is refused and the correct form is shown. Every numeral from 1 to 3999 is round tripped in the tests, which is the entire domain rather than a sample of it.

Questions

Why is IIII refused when it is on clock faces?
Because it is not a standard numeral, and standard numerals are what this converts. The clock face convention is real and is a separate thing. Four is written IV, and the tool says so rather than accepting both and being inconsistent.
Why do the numerals stop at 3999?
Because M is the largest symbol, and standard numerals do not repeat a symbol more than three times. 3999 is MMMCMXCIX and there is no standard way to write 4000. The overline notation for larger numbers exists and is not part of the standard set.
How does it know which direction I want?
From what you typed. Digits convert to a numeral and letters convert to a number, so there is no direction to choose and no way to choose it wrongly.