Aug
13
2011
13
2011
Function: Integer to Roman numerals
Small function for converting integer into roman numbers. ie 2012 = MMXII
// Integer to Roman numerals - mgear - 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, 40, 10, 9, 5, 4, 1);
var roman=new Array("M", "CM", "D","CD", "C","XC","L","XL","X","IX","V","IV","I");
var i:int;
var result="";
for (i = 0; i < 13; i++)
{
while (value >= arabic[i])
{
result = result + roman[i].ToString();
value = value - arabic[i];
}
}
return result;
}
function Start()
{
print("2012:"+int2roman(2012));
}
Tags: function, javascript
Related Posts
2 Comments + Add Comment
Leave a comment
Recent posts
- Adding Real World Location to Ice Fishing Prototype
- [web tool] Image Channel Inspector : AlphaScope
- Editor Tool: Smart Recompile (don’t recompile if edit comments)
- Editor Tool: Scene Size Analyzer
- LudumDare 60: Old Tech
- uBasic Scripting Language for Unity
- GreaseMonkey+Editor Plugin: 1-Click Copy script from ChatGPT (Web) to Unity Editor (as script)
- Editor Tool: Property Watcher
- .unityignore : Hide files from Project window
- PostBuild Script to Create Single exe Standalone File
- Game Loop Designer
- Favorites in PackageManager
Recent Comments
Support my work at Bags.fm:
Coin:
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
Subscribe to Blog via Email
Tag Cloud
2d
3D
AI
algorithm
android
asset
build
color
custom
demo
editor
effect
fake
free
game
generator
greasemonkey
indie
javascript
light
line
ludumdare
ludum dare
mesh
paint
particles
physics
plugin
proto
prototype
script
sea
shader
shadow
sprite
terrain
texture
tool
tutorial
ui
unity
vertex
visibility
water
waves
An article by












Very good
[…] of fun and challenge to the task. Shoutout to “mgear” on unitycoder.com- here is the link to the code I […]