Convert to Roman Numerals
Would you like to display numbers on your web page in Roman numerals? Well all you need to do to be able to do so is to copy one simple function. First let's take a look at how it works.
To convert a number between 1 and 3999 to roman numerals enter the number in the top box below and select 'classical' or 'original' to choose which form of Roman numerals you wish to convert to. For example 19 converts to XIX (classical form) or XVIIII (original form).
If you want to be able to do these conversions on your site then the first step is to select the code from the text box below (there is a highlight all button beneath it to make this easier) and copy it into a file called roman.js.
Next you link the script into the head of your page using the following code:
The final step is to call the script to perform the conversions for you. To get a number converted to the original roman numeral format (which didn't use subtraction) you use:
var romnum = roman(num,0);
To convert to the more familiar classical style use:
var romnum = roman(num,1);