toRoman

Converts an integer to a roman number.

string
toRoman
(
uint num
)

Return Value

Type: string

A roman number or an empty string if the given number could not be converted.

Examples

assert(toRoman(1) == "I");
assert(toRoman(3) == "III");
assert(toRoman(4) == "IV");
assert(toRoman(5) == "V");
assert(toRoman(9) == "IX");
assert(toRoman(10) == "X");
assert(toRoman(33) == "XXXIII");
assert(toRoman(1111) == "MCXI");
assert(toRoman(1999) == "MCMXCIX");
assert(toRoman(550) == "DL");
assert(toRoman(400) == "CD");
assert(toRoman(40) == "XL");

// invalid
assert(toRoman(0) == "");

Meta