Module:Roman Numeral: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 43: Line 43:
end
end


-- function overline(s)
function overline(s)
--     return mw.ustring.format( '<span style="text-decoration:overline;">%s</span>', s )
     return mw.ustring.format( '<span style="text-decoration:overline;">%s</span>', s )
end
 
-- local function overline(s)
--    local str = ''
--    for c in s:gmatch('.') do
--        str = str .. c .. '\u{305}'
--    end
--    return str
-- end
-- end
local function overline(s)
    local str = ''
    for c in s:gmatch('.') do
        str = str .. c --.. '\u{305}'
    end
    return str
end


local function truncate(f, n)
local function truncate(f, n)
Line 118: Line 118:
     local twentyFourths = {"", "Σ", "·", "·Σ", ":", ":Σ", "∴", "∴Σ", "∷", "∷Σ", "⁙", "ΣS", "S", "SΣ", "S·", "S·Σ", "S:", "S:Σ", "S:Σ", "S∴", "S∴Σ", "S∷", "S∷Σ", "S⁙", "S⁙Σ"}
     local twentyFourths = {"", "Σ", "·", "·Σ", ":", ":Σ", "∴", "∴Σ", "∷", "∷Σ", "⁙", "ΣS", "S", "SΣ", "S·", "S·Σ", "S:", "S:Σ", "S:Σ", "S∴", "S∴Σ", "S∷", "S∷Σ", "S⁙", "S⁙Σ"}
     local thirds = {truncate(1/3, 4), truncate(1/6, 4), truncate(2/3, 4), truncate(5/6, 4)}
     local thirds = {truncate(1/3, 4), truncate(1/6, 4), truncate(2/3, 4), truncate(5/6, 4)}
    local roman = ''


if args[1] == nil then return end
if args[1] == nil then return end
     local num = tonumber(args[1])
     local num = tonumber(args[1])
     if not num or num < 0 or num == math.huge then
     if not num or num == math.huge then
     return {'',''}
     return {'',''}
     elseif num == 0 then
     elseif num == 0 then
         return {'N','\n0 is represented by N'}
         return {'N','\n0 is represented by N'}
    elseif num < 0 then
        roman = '-'
     end
     end


    local roman = ''
     local explanation = "\n"
     local explanation = "\n"
     local count = 0
     local count = 0

Navigation menu