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
- 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)
- Check if point is inside polygon 2D (using line intersection)
- UnityHub: Enable Create Project Button (without having to select Cloud Organization)
- UI: Make Tooltip background fit Text content length
- Pong-Wars in Unity
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub)
- UnityHub: Add support for custom project title (instead of folder name) or use ProductName
- Testing Unity MUSE AI
Recent Comments
@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 […]