1. Tech

Your suggestion is on its way!

An email with a link to:

http://javascript.about.com/library/blroman.htm

was emailed to:

Thanks for sharing About.com with others!

Convert to Roman Numerals

clr gif
Join the Discussion

Questions? Comments?

Elsewhere on About

What are 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:

<script type="text/javascript" src="roman.js">
</script>

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);
Related Video
Convert Color Photos to Black and White in Photoshop

©2014 About.com. All rights reserved.