<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="uz">
	<id>https://ziyosfera.uz/index.php?action=history&amp;feed=atom&amp;title=Modul%3ARoman</id>
	<title>Modul:Roman - Oʻzgarishlar tarixi</title>
	<link rel="self" type="application/atom+xml" href="https://ziyosfera.uz/index.php?action=history&amp;feed=atom&amp;title=Modul%3ARoman"/>
	<link rel="alternate" type="text/html" href="https://ziyosfera.uz/index.php?title=Modul:Roman&amp;action=history"/>
	<updated>2026-11-18T23:19:22Z</updated>
	<subtitle>Ziyosferadagi mazkur sahifaning oʻzgarishlar tarixi</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://ziyosfera.uz/index.php?title=Modul:Roman&amp;diff=110356&amp;oldid=prev</id>
		<title>Programmer: Oʻzbekcha Vikipediyadan import qilindi.</title>
		<link rel="alternate" type="text/html" href="https://ziyosfera.uz/index.php?title=Modul:Roman&amp;diff=110356&amp;oldid=prev"/>
		<updated>2026-08-06T12:11:52Z</updated>

		<summary type="html">&lt;p&gt;Oʻzbekcha Vikipediyadan import qilindi.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Yangi sahifa&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{Roman}}.&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;
-- This function contains the core logic for converting numbers to Roman numerals.&lt;br /&gt;
-- It is designed to be called by both p.main (for #invoke) and p.toRoman (for module-to-module calls).&lt;br /&gt;
local function _getRomanNumerals(num_input)&lt;br /&gt;
    -- Get input and exit displaying nothing if the input is empty.&lt;br /&gt;
    if num_input == nil then return end&lt;br /&gt;
    local num = tonumber(num_input)&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; .. tostring(num_input), 2) -- tostring qo&amp;#039;shildi&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;
        -- Agar _main dan chaqirilmasa, args[2] mavjud bo&amp;#039;lmaydi.&lt;br /&gt;
        -- Shuning uchun aniq N/A qaytaramiz.&lt;br /&gt;
        return &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;
    -- The fractional part logic is typically not needed for century/year conversion&lt;br /&gt;
    -- but if you want to enable it for p.main, you would pass a &amp;#039;fraction&amp;#039; arg.&lt;br /&gt;
    -- For direct module calls (p.toRoman), we assume no fractions.&lt;br /&gt;
    -- if args.fraction == &amp;#039;yes&amp;#039; then ... end&lt;br /&gt;
&lt;br /&gt;
    return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The main entry point for #invoke.&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;
        -- Check if frame.args are explicitly provided to #invoke (e.g., {{#invoke:Roman|main|123}})&lt;br /&gt;
        -- If not, fall back to parent frame&amp;#039;s args (e.g., {{Roman|123}})&lt;br /&gt;
        if next(frame.args) then -- next(table) returns nil if table is empty&lt;br /&gt;
             origArgs = frame.args&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        origArgs = frame&lt;br /&gt;
    end&lt;br /&gt;
&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 next(args) == nil then return &amp;#039;&amp;#039; end -- next(args) == nil tekshiruvi yaxshiroq&lt;br /&gt;
    &lt;br /&gt;
    -- Given mathematical expression, simplify to a number&lt;br /&gt;
    -- mw.ext.ParserFunctions.expr is not always available in all Lua environments.&lt;br /&gt;
    -- This part might need adjustment depending on your Ziyo&amp;#039;s setup.&lt;br /&gt;
    if type(args[1]) == &amp;#039;string&amp;#039; and mw.ext and mw.ext.ParserFunctions and mw.ext.ParserFunctions.expr 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;
        else&lt;br /&gt;
            -- Agar expr xato bersa, asl stringni saqlab qolamiz va _getRomanNumerals ichida tonumber xato beradi&lt;br /&gt;
            -- yoki siz bu yerda boshqacha ishlov berishingiz mumkin.&lt;br /&gt;
            -- Hozircha shunchaki asl qiymatni qoldiramiz.&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    -- p.main _getRomanNumerals funksiyasiga args[1] ni beradi&lt;br /&gt;
    return _getRomanNumerals(args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- The new entry point for direct module-to-module calls (e.g., from Module:Wikidata/date).&lt;br /&gt;
-- This function converts a given number directly to Roman numerals.&lt;br /&gt;
function p.toRoman(number_input)&lt;br /&gt;
    -- We simply call our core logic function with the provided number.&lt;br /&gt;
    return _getRomanNumerals(number_input)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Programmer</name></author>
	</entry>
</feed>