Aug
13
2011
13
2011
Function: Integer to Roman numerals
An article by mgear
2 Comments
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
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
@unitycoder_com
My TweetsSubscribe to Blog via Email
Tag Cloud
2d
3D
AI
algorithm
android
asset
build
color
custom
demo
editor
effect
error
fake
free
game
generator
greasemonkey
indie
javascript
light
line
ludumdare
mesh
paint
particles
physics
plugin
proto
prototype
script
sea
shader
shadow
sprite
terrain
texture
tutorial
ui
unity
vertex
visibility
water
waves
webgl
Very good
[…] of fun and challenge to the task. Shoutout to “mgear” on unitycoder.com- here is the link to the code I […]