Welcome to BlogDogIt Monday, July 04 2022 @ 04:46 AM EDT

## Roman Numeral Converter

• Contributed by:
• Views: 8,070 Click "Read More" for the script ==>

## A great many people arrive on this page looking for information on how to handle large number values with Roman Numerals. This converter can only convert up to 3,999,999 because of conventional rules. However, you may find the following information useful. ### Large Roman Numerals

```Date: 08/15/97 at 10:52:53
From: Eppie
Subject: Roman numerals

Could you please convert 5000, 1,000,000, and 5,000,000 into Roman
numerals?
```

```Date: 08/22/97 at 11:35:14
From: Doctor Cheryl
Subject: Re: Roman numerals

I had to look for a while to find the information I remembered about
how to write really large numbers in Roman numerals.  According to an
old 1960 mathematics textbook called "Mathematics second course"  by
Brown, Gordey, Sward and Mayor, the Roman numeral system worked like
this:

I = 1, V = 5, L = 50, C = 100 and M = 1000.

If a heavy bar was placed over the numeral that meant it was
multiplied by 1000.  A V with a bar over it would stand for 5000.  An
M with a bar would be 1,000,000.  How would YOU write your last
numeral: 5,000,000?

For more about Egyptian and Roman Numerals, see the Math Forum
Internet News for 27 October, 1997:

and see the Dr. Math FAQ:

Roman Numerals
http://mathforum.org/dr.math/faq/faq.roman.html

-Doctors Cheryl and Sarah,  The Math Forum
Check out our web site!  http://mathforum.org/dr.math/
```

```Date: 02/28/2006 at 04:12:25
From: Arnold
Subject: Roman Numerals

How do you write a decimal number higher than 4,000,000?

I found it to be interesting that the rules state that you can only
use a particular letter 3 times max (if I'm not mistaken).  Therefore
if I use MMMM with a bar on top to signify 4,000,000, it would break
the 3 letter max rule.  The other way I can think of is to use two
bars but would that be right?
```

```Date: 02/28/2006 at 09:57:02
From: Doctor Peterson
Subject: Re: Roman Numerals

Hi, Arnold.

The basic answer is that the Romans rarely bothered to write such
large numbers, so they never developed a convenient way to do it,
just several ad-hoc tricks to extend the system a bit. One is the
bar (though I think that was a later addition); another earlier
trick was to put what we might call parentheses around a number to
multiply it by 1000. That is, something like (|) was an early form
of M=1000, and they would use ((|)) for 1,000,000 and so on. I don't
know whether using double bars is considered valid, either in the
sense of having been used historically, or of being commonly
accepted today. But it makes sense, and I know some people use it
when needed.

The 3-times rule is not really a rule, and was not followed by the
Romans themselves, who often write IIII for 4. The "rule" just
arises from the fact that, once the subtraction rule was developed,
it was not _necessary_ to use more than 3 of anything. When you get
up to MMMM, there is no alternative, so the rule does not really
apply; it _is_ necessary to repeat four or more times, if you choose
not to use the bar. So my answer to your question would be
_____
MMMMM = 5,000,000

and I wouldn't be bothered by

==
IV

Here is one discussion of the details I've mentioned:

Roman Numerals - How They Work
http://www.web40571.clarahost.co.uk/roman/howtheywork.htm#larger

Look higher on the page for some examples of how the Romans broke
the modern "rules".

If you have any further questions, feel free to write back.

- Doctor Peterson, The Math Forum
Check out our web site!  http://mathforum.org/dr.math/
```

``````<script type="text/javascript">
function convert() {
var inputNum = document.formConvert.inputNumber.value;
var arabicVal, romanVal;
switch ( convertType(inputNum) ) {
case 'RtoA':
arabicVal = RtoA(inputNum);
if(arabicVal != -1){
romanVal = AtoR(arabicVal);
}
else {
arabicVal = ''; romanVal = ''; inputNum.value = '';
}
break;
case 'AtoR':
arabicVal = inputNum;
romanVal = AtoR(arabicVal);
break;
default:
arabicVal = ''; romanVal = ''; inputNum.value = '';
return false;
}
document.formConvert.romanNumber.value = romanVal;
document.formConvert.arabicNumber.value = arabicVal;
}

function AtoR(arabic){
if (arabic > 3999999 || arabic < 1){
return 'Expect number from 1 to 3,999,999';
}
var r_nums = getRnums();
var a_nums = getAnums();
var remainder = parseInt(arabic);
var roman = '', count = 0;

var len=r_nums.length;
for ( var i=1;  i<len; ++i ){
while(remainder >= parseInt(a_nums[i]) ){
if((count++) > 30) return -1;
roman = roman + r_nums[i];
remainder = remainder - a_nums[i];
}
if(remainder <= 0)break;
}
return roman;
}

function RtoA(roman){
var r_nums = getRnums();
var a_nums = getAnums();
var remainder = roman.replace(/i/g, "M");
var arabic = 0, count = 0, test = remainder;

var len=r_nums.length;
for ( var i=1;  i<len; ++i ){
var numchrs = r_nums[i].length;
while( remainder.substr(0,numchrs) === r_nums[i]){
if((count++) > 30) return -1;
arabic += a_nums[i];
remainder = remainder.substr(numchrs,remainder.length-numchrs);
}
if(remainder.length <= 0) break;
}
if(remainder.length !==0 ){
alert(roman + " INVALID truncating to "+test.replace(remainder,'') );
}
if( (0 < arabic) && (arabic < 4000000) )return arabic;
else return -1;
}

function convertType(inputNum) {
if (inputNum.match("^([IVXLCDMivxlcdm]+)&#36;")) {
if (inputNum.length <= 27) {
return 'RtoA';
} else {
alert(inputNum + " cannot be converted");
return -1;
}
} else if (inputNum.match("^([0-9]+)&#36;")) {
var inputInt = parseInt(inputNum);
if ((inputNum > 0) && (inputNum < 4000000)) {
return "AtoR";
} else {
alert(inputNum + " out of range - must be from 1 to 3,999,999");
return -1;
}
} else {
alert(inputNum + " cannot be converted");
return -1;
}
}

function getRnums() {
var r_nums = Array();
r_nums = 'm';
r_nums = 'cm';
r_nums = 'd';
r_nums = 'cd';
r_nums = 'c';
r_nums = 'xc';
r_nums = 'l';
r_nums = 'xl';
r_nums = 'x';
r_nums = 'Mx';
r_nums = 'v';
r_nums = 'Mv';
r_nums = 'M';
r_nums = 'CM';
r_nums = 'D';
r_nums = 'CD';
r_nums = 'C';
r_nums = 'XC';
r_nums = 'L';
r_nums = 'XL';
r_nums = 'X';
r_nums = 'IX';
r_nums = 'V';
r_nums = 'IV';
r_nums = 'I';
return r_nums;
}
function getAnums() {
var a_nums = Array();
a_nums = 1000000;
a_nums = 900000;
a_nums = 500000;
a_nums = 400000;
a_nums = 100000;
a_nums = 90000;
a_nums = 50000;
a_nums = 40000;
a_nums = 10000;
a_nums = 9000;
a_nums = 5000;
a_nums = 4000;
a_nums = 1000;
a_nums = 900;
a_nums = 500;
a_nums = 400;
a_nums = 100;
a_nums = 90;
a_nums = 50;
a_nums = 40;
a_nums = 10;
a_nums = 9;
a_nums = 5;
a_nums = 4;
a_nums = 1;
return a_nums;
}

</script>``````

Thank you for visiting BlogDogIt Please have a look around...
There is Lots and Lots of interesting stuff on this site.