Roman Numerals From Integers

CK CK 3788 
Created at  
509 0 0



Converts integers to romans. ported with permission from a VBScrpt by Bill
Wilkinson - cavetas apply - see source
 
/*
Ported to JScript from a VBS script by Bill Wilkinson

all rights for this implementation - jason@atrax.co.uk

you may reuse this code as you see fit. modifications should be re-released into the public domain, and a copy emailed to the author(s).

http://www.infinitemonkeys.ws/

*/


function getNumeral(intNum) {
 var arrDigits = new Array("I","V","X","L","C","D","M", "<U>V</U>","<U>X</U>","<U>L</U>", "<U>C</U>","<U>D</U>","<U>M</U>", "?","?");
  if(intNum<0||intNum>39999999) {
   return "Error";
  }
  var result = '';
  for(var x=0;x<7;x++) {
    intDig = intNum % 10;
    intStartD = x * 2;
    one = arrDigits[intStartD];
          five = arrDigits[intStartD+1];
          ten = arrDigits[intStartD+2];
     if(intDig==9) {
      result = one + ten + result;
     } else if(intDig==4)  {
      result = one + five + result;
     } else {
      var temp = "";
               if(intDig >= 5) {
      temp = five;
      }    
                for(i=1;i<=(intDig%5);i++) {
                    temp += one;
                }
               result = temp + result;      
     }
   intNum = parseInt(intNum/10);
   }
   return result ;
}


WScript.Echo(getNumeral(1979))

Tags Algorithm HTML Javascript Roman Numerals Facebook X
Comments 0
Similar posts
  1. Get A Print Dialog Box By Clicking A Button
    817
  2. Linking Drop Downs
    574
  3. Keyboard event detection (Key Tracker)
    1,084
  4. IsIn For Arrays
    566
  5. Example Of Creating Objects
    401
  6. Printing A Page
    376
  7. Cross Browser Event Management Functions Using JavaScript
    608
  8. Javascript & Cookie based Visitor Application
    434
  9. How to record visitor's name by Cookie
    410
  10. Save And Restore Form Cookies in Javascript
    333
  11. Let popup once for event dialog or something like that in Javascript
    421
  12. New content notifier in Javascript
    592
  13. Cookie Redirect
    491
  14. Cookie enabled browser checking in Javascript
    338
  15. Access Granted
    582
  16. Greeting For The Time Of Day
    392
  17. Displays the number of pages that the users browser has displayed in its session
    661
  18. Address Book
    574
  19. Basic Date Display
    508
  20. Javascript implemented Calendar
    420
  21. Javascript based Alarm Clock
    659
  22. How to get date time in Javascript ?
    497
  23. Hiding HTML on the browser
    457
  24. Getting WebSearchers On Your Site
    372
  25. Javascript Mouse Event Handler Example
    403
  26. Select And Deselect All Checkboxes By Javascript
    630
  27. Confirm The Link Clicked
    628
  28. Enlarge Image
    511
  29. Dual Scroller
    329
  30. Cursor Changer
    382
  1. Address Book
    574
  2. Displays the number of pages that the users browser has displayed in its session
    661
  3. Greeting For The Time Of Day
    392
  4. Access Granted
    582
  5. Cookie enabled browser checking in Javascript
    338
  6. Cookie Redirect
    491
  7. New content notifier in Javascript
    592
  8. Let popup once for event dialog or something like that in Javascript
    421
  9. Save And Restore Form Cookies in Javascript
    333
  10. How to record visitor's name by Cookie
    410
  11. Javascript & Cookie based Visitor Application
    434
  12. Cross Browser Event Management Functions Using JavaScript
    608
  13. Printing A Page
    376
  14. Example Of Creating Objects
    401
  15. Linking Drop Downs
    574
  16. Get A Print Dialog Box By Clicking A Button
    817
  17. Keyboard event detection (Key Tracker)
    1,084
  18. IsIn For Arrays
    566
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,707
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    217
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    85
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    197
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    508
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    232
  17. The Concept of Scaffolding in AI Agents
    221
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    575
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    252
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    326
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    197
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252