{"id":80,"date":"2011-08-13T14:50:38","date_gmt":"2011-08-13T11:50:38","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=80"},"modified":"2011-08-13T14:50:38","modified_gmt":"2011-08-13T11:50:38","slug":"function-integer-to-roman-numerals","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2011\/08\/13\/function-integer-to-roman-numerals\/","title":{"rendered":"Function: Integer to Roman numerals"},"content":{"rendered":"<p>Small function for converting integer into roman numbers. ie 2012 = MMXII<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\/\/ Integer to Roman numerals - mgear - http:\/\/unitycoder.com\/blog\/\r\n\/\/ Unity3D version converted from this: http:\/\/rosettacode.org\/wiki\/Roman_numerals\/Encode\r\n\r\nfunction int2roman(value:int)\r\n{\r\nvar arabic=new Array(1000, 900, 500, 400, 100, 90, 50,\u00a0 40,\u00a0 10,\u00a0 9,\u00a0 5,\u00a0\u00a0 4,\u00a0 1);\r\nvar roman=new Array(&quot;M&quot;, &quot;CM&quot;, &quot;D&quot;,&quot;CD&quot;, &quot;C&quot;,&quot;XC&quot;,&quot;L&quot;,&quot;XL&quot;,&quot;X&quot;,&quot;IX&quot;,&quot;V&quot;,&quot;IV&quot;,&quot;I&quot;);\r\nvar i:int;\r\nvar result=&quot;&quot;;\r\nfor (i = 0; i &lt; 13; i++)\r\n{\r\nwhile (value &gt;= arabic&#x5B;i])\r\n{\r\nresult = result + roman&#x5B;i].ToString();\r\nvalue\u00a0 = value - arabic&#x5B;i];\r\n}\r\n}\r\nreturn result;\r\n}\r\n\r\nfunction Start()\r\n{\r\nprint(&quot;2012:&quot;+int2roman(2012));\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Small function for converting integer into roman numbers. ie 2012 = MMXII \/\/ Integer to Roman numerals &#8211; mgear &#8211; http:\/\/unitycoder.com\/blog\/ \/\/ Unity3D version converted from this: http:\/\/rosettacode.org\/wiki\/Roman_numerals\/Encode function int2roman(value:int) { var arabic=new Array(1000, 900, 500, 400, 100, 90, 50,\u00a0 40,\u00a0 10,\u00a0 9,\u00a0 5,\u00a0\u00a0 4,\u00a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[23,3],"tags":[24,18],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-functions-unity3d","category-unity3d","tag-function","tag-javascript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-1i","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":3,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":299,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions\/299"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}