Solved

Roman Numeral Conversion

Posted on 2000-02-14
1
510 Views
Last Modified: 2010-05-18
I would like to use a roman numeral as my copyright year.  What is the conversion code I need to use?
0
Comment
Question by:tecmaster
1 Comment
 
LVL 6

Accepted Solution

by:
tecbuilder earned 400 total points
ID: 2521389
I developed this for a pascal program I wrote quite a while ago and later converted it to JavaScript to convert any integer to Roman Numeral and Roman Numeral to integer.  I believe it will do what you want.

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function convertInteger(N) {
  var valRN = new Array (1,4,5,9,10,40,50,90,100,400,500,900,1000);
  var textRN = new Array ("I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M");
  var theValue = "";
  while (N > 0) {
    i = 12;
    while(valRN[i] > N) i--;
    numRN = Math.floor(N / valRN[i]);
    for (j=1;j<=numRN;j++) theValue += textRN[i];
    N = N % valRN[i];
  }
  return theValue;
}

// -->
</SCRIPT>
</HEAD>

<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write("Copyright &copy; " + convertInteger(2000));
//-->
</SCRIPT>

</BODY>
</HTML>

tec
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question