Solved

Roman Numeral Conversion

Posted on 2000-02-14
1
477 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now