ሞድዩል:Numbers
Appearance
Documentation for this module may be created at ሞድዩል:Numbers/doc
local z = {}
function z.Roman(frame)
local number,arguments,parent
local MinorRomanNumbers4000 = {
{3000, "MMM"},{2000, "MM"},{1000, "M"},
{900, "CM"}, {800, "DCCC"}, {700, "DCC"}, {600, "DC"}, {500, "D"}, {400, "CD"},
{300, "CCC"}, {200, "CC"}, {100, "C"},
{90, "XC"},{80, "LXXX"},{70, "LXX"},{60, "LX"}, {50, "L"}, {40, "XL"},
{30, "XXX"},{20, "XX"},{10, "X"},
{9, "IX"}, {8, "VIII"},{7, "VII"},{6, "VI"}, {5, "V"}, {4, "IV"},
{3, "III"},{2, "II"}, {1, "I"}
}
if type(frame) == 'number' then -- To be able to call it from another module easily
number = frame
else
arguments = frame.args;
parent = frame:getParent();
number = tonumber(arguments[1] or parent.args[1]) --Decimal number to be converted to Roman numerals
end
if number == nil or number == "" or number >= 4000 then return "" end
local result = ''
for _, v in ipairs( MinorRomanNumbers4000 ) do
local value, letters = unpack( v )
if number >= value then
number = number - value
result = result .. letters
end
end
return result
end
return z