Posted By

Scooter on 08/30/08


Tagged

roman numerals


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wizard04


BigRoman


 / Published in: ASP
 

URL: http://reusablecode.blogspot.com/2008/08/roman-numerals-part-3.html

Handles arabic numbers larger than 4999. Requires my roman() function.

  1. <%
  2. ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
  3. '
  4. ' This work is licensed under the Creative Commons Attribution License. To view
  5. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  6. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  7. ' 94305, USA.
  8.  
  9. ' Convert Arabic numerals into Roman numerals.
  10. ' REQUIRES: roman()
  11. function bigroman(ByVal arabic)
  12. dim thousands
  13.  
  14. thousands = Array("", "M", "MM", "MMM", "M(V)", "(V)", "(V)M", "(V)MM", "(V)MMM", "M(X)")
  15.  
  16. if arabic >= 10000 then
  17. bigroman = "(" & roman((arabic - (arabic mod 10000)) / 1000) & ")"
  18. arabic = arabic mod 10000
  19. end if
  20.  
  21. bigroman = bigroman & thousands((arabic - (arabic mod 1000)) / 1000)
  22. arabic = arabic mod 1000
  23. bigroman = bigroman & roman(arabic)
  24.  
  25. ' Convert parentheses to <span> tags.
  26. bigroman = replace(bigroman, "(", "<span style=""text-decoration: overline"">")
  27. bigroman = replace(bigroman, ")", "</span>")
  28. end function
  29. %>

Report this snippet  

You need to login to post a comment.