Technopedia Center
PMB University Brochure
Faculty of Engineering and Computer Science
S1 Informatics S1 Information Systems S1 Information Technology S1 Computer Engineering S1 Electrical Engineering S1 Civil Engineering

faculty of Economics and Business
S1 Management S1 Accountancy

Faculty of Letters and Educational Sciences
S1 English literature S1 English language education S1 Mathematics education S1 Sports Education
  • Registerasi
  • Brosur UTI
  • Kip Scholarship Information
  • Performance
  1. Weltenzyklopädie
  2. Module:Romain — Wikipédia
Module:Romain — Wikipédia 👆 Click Here! Read More..
Cette page fait l’objet d’une mesure de semi-protection étendue.
Une page de Wikipédia, l'encyclopédie libre.

 Documentation[créer] [purger]
MIT

Ce module ne possède aucune documentation explicative en sous-page, pas même une description succincte.
Vous pouvez créer cette sous-page afin de documenter ce module adéquatement.

La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.

    • Projet Scribunto Projet Scribunto
local p = {}

-- barre horizontale au-dessus des nombres élevés
local function overline( s )
    return '<span style="text-decoration:overline">' .. s .. '</span>'
end

-- Gets the Roman numerals for a given numeral table. Returns both the string of
-- numerals and the value of the number after it is finished being processed.
local function getLetters( num, t )
    local ret = {}
    for _, v in ipairs( t ) do
        local val, letter = unpack( v )
        while num >= val do
            num = num - val
            table.insert( ret, letter )
        end
    end
    return table.concat( ret ), num
end


function p.toRoman( num, default )
    num = tonumber( num )
    if not num or num < 1 or num == math.huge then
        return
    end
    num = math.floor( num )
    
    -- Return a message for numbers too big to be expressed in Roman numerals.
    if num >= 5000000 then
        return default or 'N/A'
    end
    
    local ret = ''
    -- Find the Roman numerals for the large part of numbers 5000 and bigger.
    -- The if statement is not strictly necessary, but makes the algorithm 
    -- more efficient for smaller numbers.
    if num >= 5000 then
        local bigRomans = {
            { 1000000, 'M' },
            { 900000, 'CM' }, { 500000, 'D' }, { 400000, 'CD' }, { 100000, 'C' },
            { 90000, 'XC' }, { 50000, 'L' }, { 40000, 'XL' }, { 10000, 'X' },
            { 5000, 'V' }
        }
        local bigLetters
        bigLetters, num = getLetters( num, bigRomans )
        ret = overline( bigLetters )
    end
    
    -- Find the Roman numerals for numbers 4999 or less.
    local smallRomans = {
        {1000, "M"},
        {900, "CM"}, {500, "D"}, {400, "CD"}, {100, "C"},
        {90, "XC"}, {50, "L"}, {40, "XL"}, {10, "X"},
        {9, "IX"}, {5, "V"}, {4, "IV"}, {1, "I"} 
    }
    local smallLetters = getLetters( num, smallRomans )
    ret = ret .. smallLetters
    
    return ret

end

function p.fromRoman( str, default )
	local strOrig = str
	str = str:upper()
	if not str:find( '^[MDCLXVI]+$' ) then
		return tonumber( str ) or default or strOrig
	end
	local smallRomans = { I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000 }
	local result = 0
	local old, n = 0
	for i = str:len(), 1, -1  do
		n = smallRomans[ str:sub( i, i ) ]
		if n < old then
			result = result - n
		else
			result = result + n
			old = n
		end
	end
	return result
end

-- compatibility with [[en:Module:Roman]]
function p._main(args)
	return p.toRoman( args[1] )
end

function p.main( frame )
	return p.nombreEnRomain( frame )
end

-- functions to call the module from a template (takes the #invoke first arg or the template first arg)
function p.nombreEnRomain( frame )
	local num
	if frame == mw.getCurrentFrame() then
		num = frame.args[1] or frame:getParent().args[1]
	else
		num = frame
	end
	return p.toRoman( mw.text.trim( num or '' ) )
end

function p.nombreDepuisRomain( frame )
	local str
	if frame == mw.getCurrentFrame() then
		str = frame.args[1] or frame:getParent().args[1]
	else
		str = frame
	end
	return p.fromRoman( mw.text.trim( str or '' ) )
end
	
return p
Ce document provient de « https://fr.teknopedia.teknokrat.ac.id/w/index.php?title=Module:Romain&oldid=143439666 ».
Catégories :
  • Module sans documentation
  • Module en langage Lua
Catégorie cachée :
  • Module en semi-protection étendue

  • indonesia
  • Polski
  • الرية
  • Deutsch
  • English
  • Español
  • Français
  • Italiano
  • مصر
  • Nederlands
  • 本語
  • Português
  • Sinugboanong Binisaya
  • Svenska
  • Українска
  • Tiếng Việt
  • Winaray
  • 中文
  • Русски
Sunting pranala
Pusat Layanan

UNIVERSITAS TEKNOKRAT INDONESIA | ASEAN's Best Private University
Jl. ZA. Pagar Alam No.9 -11, Labuhan Ratu, Kec. Kedaton, Kota Bandar Lampung, Lampung 35132
Phone: (0721) 702022
Email: pmb@teknokrat.ac.id