<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://the-democratika.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ARoman</id>
	<title>Module:Roman - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://the-democratika.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ARoman"/>
	<link rel="alternate" type="text/html" href="https://the-democratika.com/wiki/index.php?title=Module:Roman&amp;action=history"/>
	<updated>2026-04-04T17:50:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://the-democratika.com/wiki/index.php?title=Module:Roman&amp;diff=5971&amp;oldid=prev</id>
		<title>&gt;Uzume: strict</title>
		<link rel="alternate" type="text/html" href="https://the-democratika.com/wiki/index.php?title=Module:Roman&amp;diff=5971&amp;oldid=prev"/>
		<updated>2023-02-08T20:14:10Z</updated>

		<summary type="html">&lt;p&gt;strict&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{Roman}}.&lt;br /&gt;
require[[strict]]&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- This function implements the {{overline}} template.&lt;br /&gt;
local function overline(s)&lt;br /&gt;
    return mw.ustring.format( &amp;#039;&amp;lt;span style=&amp;quot;text-decoration:overline;&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;&amp;#039;, s )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Gets the Roman numerals for a given numeral table. Returns both the string of&lt;br /&gt;
-- numerals and the value of the number after it is finished being processed.&lt;br /&gt;
local function getLetters(num, t)&lt;br /&gt;
    local ret = {}&lt;br /&gt;
    for _, v in ipairs(t) do&lt;br /&gt;
        local val, letter = unpack(v)&lt;br /&gt;
        while num &amp;gt;= val do&lt;br /&gt;
            num = num - val&lt;br /&gt;
            table.insert(ret, letter)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return table.concat(ret), num&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The main control flow of the module.&lt;br /&gt;
local function _main(args)&lt;br /&gt;
    -- Get input and exit displaying nothing if the input is empty.&lt;br /&gt;
    if args[1] == nil then return end&lt;br /&gt;
    local num = tonumber(args[1])&lt;br /&gt;
    if not num or num &amp;lt; 0 or num == math.huge then&lt;br /&gt;
    	error(&amp;#039;Invalid number &amp;#039; .. args[1], 2)&lt;br /&gt;
    elseif num == 0 then&lt;br /&gt;
        return &amp;#039;N&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Return a message for numbers too big to be expressed in Roman numerals.&lt;br /&gt;
    if num &amp;gt;= 5000000 then&lt;br /&gt;
        return args[2] or &amp;#039;N/A&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local ret = &amp;#039;&amp;#039;&lt;br /&gt;
    -- Find the Roman numerals for the large part of numbers.&lt;br /&gt;
    -- 23 April 2016 - tweaked to &amp;gt;= 4000 to accept big Roman &amp;#039;IV&amp;#039;&lt;br /&gt;
    -- The if statement is not strictly necessary, but makes the algorithm &lt;br /&gt;
    -- more efficient for smaller numbers.&lt;br /&gt;
    if num &amp;gt;= 4000 then&lt;br /&gt;
        local bigRomans = {&lt;br /&gt;
            { 1000000, &amp;#039;M&amp;#039; },&lt;br /&gt;
            { 900000, &amp;#039;CM&amp;#039; }, { 500000, &amp;#039;D&amp;#039; }, { 400000, &amp;#039;CD&amp;#039; }, { 100000, &amp;#039;C&amp;#039; },&lt;br /&gt;
            {  90000, &amp;#039;XC&amp;#039; }, {  50000, &amp;#039;L&amp;#039; }, {  40000, &amp;#039;XL&amp;#039; }, {  10000, &amp;#039;X&amp;#039; },&lt;br /&gt;
            {   9000, &amp;#039;IX&amp;#039; }, {   5000, &amp;#039;V&amp;#039; }, {   4000, &amp;#039;IV&amp;#039; },&lt;br /&gt;
        }&lt;br /&gt;
        local bigLetters&lt;br /&gt;
        bigLetters, num = getLetters(num, bigRomans)&lt;br /&gt;
        ret = overline(bigLetters)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Find the Roman numerals for numbers less than the big Roman threshold.&lt;br /&gt;
    local smallRomans = {&lt;br /&gt;
        { 1000, &amp;#039;M&amp;#039; },&lt;br /&gt;
        { 900, &amp;#039;CM&amp;#039; }, { 500, &amp;#039;D&amp;#039; }, { 400, &amp;#039;CD&amp;#039; }, { 100, &amp;#039;C&amp;#039; },&lt;br /&gt;
        {  90, &amp;#039;XC&amp;#039; }, {  50, &amp;#039;L&amp;#039; }, {  40, &amp;#039;XL&amp;#039; }, {  10, &amp;#039;X&amp;#039; },&lt;br /&gt;
        {   9, &amp;#039;IX&amp;#039; }, {   5, &amp;#039;V&amp;#039; }, {   4, &amp;#039;IV&amp;#039; }, {   1, &amp;#039;I&amp;#039; }&lt;br /&gt;
    }&lt;br /&gt;
    local smallLetters = getLetters( num, smallRomans )&lt;br /&gt;
    ret = ret .. smallLetters&lt;br /&gt;
&lt;br /&gt;
    if args.fraction == &amp;#039;yes&amp;#039; then&lt;br /&gt;
        -- Find the Roman numerals for the fractional parts of numbers.&lt;br /&gt;
        -- If num is not a whole number, add half of 1/1728 (the smallest unit) to equate to rounding.&lt;br /&gt;
        -- Ensure we&amp;#039;re not less than the smallest unit or larger than 1 - smallest unit&lt;br /&gt;
        -- to avoid getting two &amp;quot;half&amp;quot; symbols or no symbols at all&lt;br /&gt;
        num = num - math.floor(num)&lt;br /&gt;
        if num ~= 0 then&lt;br /&gt;
            num = math.max(1.1/1728, math.min(1727.1/1728, num + 1/3456))&lt;br /&gt;
        end&lt;br /&gt;
        local fractionalRomans = {&lt;br /&gt;
            { 1/2, &amp;#039;S&amp;#039; }, { 5/12, &amp;quot;&amp;#039;&amp;#039;&amp;#039;:&amp;#039;&amp;#039;&amp;#039;•&amp;#039;&amp;#039;&amp;#039;:&amp;#039;&amp;#039;&amp;#039;&amp;quot; }, { 1/3, &amp;quot;&amp;#039;&amp;#039;&amp;#039;::&amp;#039;&amp;#039;&amp;#039;&amp;quot; },&lt;br /&gt;
            { 1/4, &amp;quot;&amp;#039;&amp;#039;&amp;#039;:&amp;#039;&amp;#039;&amp;#039;•&amp;quot; }, { 1/6, &amp;quot;&amp;#039;&amp;#039;&amp;#039;:&amp;#039;&amp;#039;&amp;#039;&amp;quot; }, { 1/12, &amp;#039;•&amp;#039; },&lt;br /&gt;
            { 1/24, &amp;#039;Є&amp;#039; }, { 1/36, &amp;#039;ƧƧ&amp;#039; }, { 1/48, &amp;#039;Ɔ&amp;#039; }, { 1/72, &amp;#039;Ƨ&amp;#039; }, { 1/144, &amp;#039;&amp;lt;s&amp;gt;Ƨ&amp;lt;/s&amp;gt;&amp;#039; },&lt;br /&gt;
            { 1/288, &amp;#039;℈&amp;#039; }, { 1/1728, &amp;#039;»&amp;#039; },&lt;br /&gt;
        }&lt;br /&gt;
        local fractionalLetters = getLetters(num, fractionalRomans)&lt;br /&gt;
        &lt;br /&gt;
        ret = ret .. fractionalLetters&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    -- If called via #invoke, use the args passed into the invoking&lt;br /&gt;
    -- template, or the args passed to #invoke if any exist. Otherwise&lt;br /&gt;
    -- assume args are being passed directly in from the debug console&lt;br /&gt;
    -- or from another Lua module.&lt;br /&gt;
    local origArgs&lt;br /&gt;
    if frame == mw.getCurrentFrame() then&lt;br /&gt;
        origArgs = frame:getParent().args&lt;br /&gt;
        for k, v in pairs(frame.args) do&lt;br /&gt;
            origArgs = frame.args&lt;br /&gt;
            break&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        origArgs = frame&lt;br /&gt;
    end&lt;br /&gt;
    -- Trim whitespace and remove blank arguments.&lt;br /&gt;
    local args = {}&lt;br /&gt;
    for k, v in pairs(origArgs) do&lt;br /&gt;
        if type( v ) == &amp;#039;string&amp;#039; then&lt;br /&gt;
            v = mw.text.trim(v)&lt;br /&gt;
        end&lt;br /&gt;
        if v ~= &amp;#039;&amp;#039; then&lt;br /&gt;
            args[k] = v&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    -- exit if not given anything&lt;br /&gt;
    if args == nil or args == {} then return end&lt;br /&gt;
    -- Given mathematical expression, simplify to a number&lt;br /&gt;
    if type(args[1]) == &amp;#039;string&amp;#039; then&lt;br /&gt;
        local success, result = pcall(mw.ext.ParserFunctions.expr, args[1])&lt;br /&gt;
        if success then&lt;br /&gt;
            args[1] = result&lt;br /&gt;
        end -- else, pass to _main routine and try to let Lua&amp;#039;s tonumber handle it&lt;br /&gt;
    end&lt;br /&gt;
    return _main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>&gt;Uzume</name></author>
	</entry>
</feed>