<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pt-BR">
	<id>https://wikincat.org/w/index.php?action=history&amp;feed=atom&amp;title=M%C3%B3dulo%3ARoman</id>
	<title>Módulo:Roman - Histórico de revisão</title>
	<link rel="self" type="application/atom+xml" href="https://wikincat.org/w/index.php?action=history&amp;feed=atom&amp;title=M%C3%B3dulo%3ARoman"/>
	<link rel="alternate" type="text/html" href="https://wikincat.org/w/index.php?title=M%C3%B3dulo:Roman&amp;action=history"/>
	<updated>2026-04-11T13:59:18Z</updated>
	<subtitle>Histórico de revisões para esta página neste wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wikincat.org/w/index.php?title=M%C3%B3dulo:Roman&amp;diff=3554&amp;oldid=prev</id>
		<title>Jaider.ferreira: Criou página com &#039;--[[ from: https://commons.wikimedia.org/wiki/Module:Roman This module converts Arabic numerals into Roman numerals. It currently works for any non-negative integer below 5 bi...&#039;</title>
		<link rel="alternate" type="text/html" href="https://wikincat.org/w/index.php?title=M%C3%B3dulo:Roman&amp;diff=3554&amp;oldid=prev"/>
		<updated>2023-01-14T22:46:10Z</updated>

		<summary type="html">&lt;p&gt;Criou página com &amp;#039;--[[ from: https://commons.wikimedia.org/wiki/Module:Roman This module converts Arabic numerals into Roman numerals. It currently works for any non-negative integer below 5 bi...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[ from: https://commons.wikimedia.org/wiki/Module:Roman&lt;br /&gt;
This module converts Arabic numerals into Roman numerals.&lt;br /&gt;
It currently works for any non-negative integer below 5 billions (up to 4 999 999 999).&lt;br /&gt;
&lt;br /&gt;
Zero is represented as &amp;quot;N&amp;quot; (from Classical Latin adverbs &amp;quot;nec&amp;quot; or &amp;quot;non&amp;quot;), like in standard CLDR data.&lt;br /&gt;
&lt;br /&gt;
For numbers starting at 4 thousands, this version no longer generates any HTML+CSS, but only plain-text:&lt;br /&gt;
standard Unicode combining diacritics are used for overlines (U+0305 for the first level,&lt;br /&gt;
then U+0304 for the second level, but both are treated equivalently when parsing Roman numbers).&lt;br /&gt;
&lt;br /&gt;
For numbers starting at 4 billions, it still uses 4 letters M with double overlines because&lt;br /&gt;
triple overlines are not supported in plain-text (this is acceptable, just like &amp;quot;MMMM&amp;quot; is also&lt;br /&gt;
acceptable for representing 4000 but this version chooses the shorter &amp;quot;IV&amp;quot; with a single overline).&lt;br /&gt;
&lt;br /&gt;
The Roman number parser will accept all valid notations (except apostrophic/Claudian/lunate notations&lt;br /&gt;
using reversed C), more than what it generates, and will correctly convert them to Arabic numbers.&lt;br /&gt;
&lt;br /&gt;
Please do not modify this code without applying the changes first at Module:Roman/sandbox and testing&lt;br /&gt;
at Module:Roman/sandbox/testcases and Module talk:Roman/sandbox/testcases.&lt;br /&gt;
&lt;br /&gt;
Authors and maintainers:&lt;br /&gt;
* User:RP88, User:Verdy_p&lt;br /&gt;
]]&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--[============[&lt;br /&gt;
   Private data&lt;br /&gt;
--]============]&lt;br /&gt;
-- See CLDR data /common/rbnf/root.xml for &amp;quot;roman-upper&amp;quot; rules. However we still don&amp;#039;t&lt;br /&gt;
-- use the rarely supported Roman extension digits after &amp;#039;M&amp;#039; (in U+2160..2188), but use&lt;br /&gt;
-- the more common notation with diacritical overlines (&amp;#039;ↁ&amp;#039;=&amp;#039;V̅&amp;#039;, &amp;#039;ↂ&amp;#039;=&amp;#039;X̅&amp;#039;, etc.).&lt;br /&gt;
-- Please avoid using HTML with &amp;quot;text-decoration:overline&amp;quot; style, but use plain-text&lt;br /&gt;
-- combining characters (U+0304 or U+0305 for single overline, U+033F for double).&lt;br /&gt;
-- In this table, combining overlines (U+0304) are preferred to macrons (U+0305), as&lt;br /&gt;
-- they align with double overlines (U+033F). None of them are precombined, so you&lt;br /&gt;
-- can easily detect and remove them from generated strings. As well the other&lt;br /&gt;
-- compatiblity forms (in the next table) are avoided in the generated strings.&lt;br /&gt;
local decimalRomans = {&lt;br /&gt;
    d0 = { [0] = &amp;#039;&amp;#039;, &amp;#039;I&amp;#039;, &amp;#039;II&amp;#039;, &amp;#039;III&amp;#039;, &amp;#039;IV&amp;#039;, &amp;#039;V&amp;#039;, &amp;#039;VI&amp;#039;, &amp;#039;VII&amp;#039;, &amp;#039;VIII&amp;#039;, &amp;#039;IX&amp;#039; },&lt;br /&gt;
    d1 = { [0] = &amp;#039;&amp;#039;, &amp;#039;X&amp;#039;, &amp;#039;XX&amp;#039;, &amp;#039;XXX&amp;#039;, &amp;#039;XL&amp;#039;, &amp;#039;L&amp;#039;, &amp;#039;LX&amp;#039;, &amp;#039;LXX&amp;#039;, &amp;#039;LXXX&amp;#039;, &amp;#039;XC&amp;#039; },&lt;br /&gt;
    d2 = { [0] = &amp;#039;&amp;#039;, &amp;#039;C&amp;#039;, &amp;#039;CC&amp;#039;, &amp;#039;CCC&amp;#039;, &amp;#039;CD&amp;#039;, &amp;#039;D&amp;#039;, &amp;#039;DC&amp;#039;, &amp;#039;DCC&amp;#039;, &amp;#039;DCCC&amp;#039;, &amp;#039;CM&amp;#039; },&lt;br /&gt;
    d3 = { [0] = &amp;#039;&amp;#039;, &amp;#039;M&amp;#039;, &amp;#039;MM&amp;#039;, &amp;#039;MMM&amp;#039;, &amp;#039;I̅V̅&amp;#039;, &amp;#039;V̅&amp;#039;, &amp;#039;V̅I̅&amp;#039;, &amp;#039;V̅I̅I̅&amp;#039;, &amp;#039;V̅I̅I̅I̅&amp;#039;, &amp;#039;I̅X̅&amp;#039; },&lt;br /&gt;
    d4 = { [0] = &amp;#039;&amp;#039;, &amp;#039;X̅&amp;#039;, &amp;#039;X̅X̅&amp;#039;, &amp;#039;X̅X̅X̅&amp;#039;, &amp;#039;X̅L̅&amp;#039;, &amp;#039;L̅&amp;#039;, &amp;#039;L̅X̅&amp;#039;, &amp;#039;L̅X̅X̅&amp;#039;, &amp;#039;L̅X̅X̅X̅&amp;#039;, &amp;#039;X̅C̅&amp;#039; },&lt;br /&gt;
    d5 = { [0] = &amp;#039;&amp;#039;, &amp;#039;C̅&amp;#039;, &amp;#039;C̅C̅&amp;#039;, &amp;#039;C̅C̅C̅&amp;#039;, &amp;#039;C̅D̅&amp;#039;, &amp;#039;D̅&amp;#039;, &amp;#039;D̅C̅&amp;#039;, &amp;#039;D̅C̅C̅&amp;#039;, &amp;#039;D̅C̅C̅C̅&amp;#039;, &amp;#039;C̅M̅&amp;#039; },&lt;br /&gt;
    d6 = { [0] = &amp;#039;&amp;#039;, &amp;#039;M̅&amp;#039;, &amp;#039;M̅M̅&amp;#039;, &amp;#039;M̅M̅M̅&amp;#039;, &amp;#039;I̿V̿&amp;#039;, &amp;#039;V̿&amp;#039;, &amp;#039;V̿I̿&amp;#039;, &amp;#039;V̿I̿I̿&amp;#039;, &amp;#039;V̿I̿I̿I̿&amp;#039;, &amp;#039;I̿X̿&amp;#039; },&lt;br /&gt;
    d7 = { [0] = &amp;#039;&amp;#039;, &amp;#039;X̿&amp;#039;, &amp;#039;X̿X̿&amp;#039;, &amp;#039;X̿X̿X̿&amp;#039;, &amp;#039;X̿L̿&amp;#039;, &amp;#039;L̿&amp;#039;, &amp;#039;L̿X̿&amp;#039;, &amp;#039;L̿X̿X̿&amp;#039;, &amp;#039;L̿X̿X̿X̿&amp;#039;, &amp;#039;X̿C̿&amp;#039; },&lt;br /&gt;
    d8 = { [0] = &amp;#039;&amp;#039;, &amp;#039;C̿&amp;#039;, &amp;#039;C̿C̿&amp;#039;, &amp;#039;C̿C̿C̿&amp;#039;, &amp;#039;C̿D̿&amp;#039;, &amp;#039;D̿&amp;#039;, &amp;#039;D̿C̿&amp;#039;, &amp;#039;D̿C̿C̿&amp;#039;, &amp;#039;D̿C̿C̿C̿&amp;#039;, &amp;#039;C̿M̿&amp;#039; },&lt;br /&gt;
    d9 = { [0] = &amp;#039;&amp;#039;, &amp;#039;M̿&amp;#039;, &amp;#039;M̿M̿&amp;#039;, &amp;#039;M̿M̿M̿&amp;#039;, &amp;#039;M̿M̿M̿M̿&amp;#039; },&lt;br /&gt;
}&lt;br /&gt;
local romanDecimals = {&lt;br /&gt;
    -- Basic Latin capital letters&lt;br /&gt;
    C = 100,&lt;br /&gt;
    D = 500, -- TODO: add Medieval &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations like &amp;quot;IƆ&amp;quot;&lt;br /&gt;
    I = 1,&lt;br /&gt;
    J = 1, -- = &amp;#039;I&amp;#039;. Modern distinct form of the formerly unified Roman letter &amp;#039;I&amp;#039;&lt;br /&gt;
    L = 50,&lt;br /&gt;
    M = 1000,&lt;br /&gt;
    N = 0, -- Abbreviated &amp;quot;nec&amp;quot; or &amp;quot;non&amp;quot; adverb in Classical Latin&lt;br /&gt;
    O = 0, -- = &amp;#039;N&amp;#039;.&lt;br /&gt;
    U = 5, -- = &amp;#039;V&amp;#039;. Modern distinct form of the formerly unified Roman letter &amp;#039;V&amp;#039;&lt;br /&gt;
    V = 5,&lt;br /&gt;
    W = 10, -- = &amp;#039;VV&amp;#039; = &amp;#039;X&amp;#039;. Modern distinct form of the former Roman archaic digram &amp;#039;VV&amp;#039; used as a numeral before &amp;#039;X&amp;#039;&lt;br /&gt;
    X = 10,&lt;br /&gt;
    Y = 2, -- = &amp;#039;IJ&amp;#039; = &amp;#039;II&amp;#039;. Uncommon ligature (borrowed from the lowercased form)&lt;br /&gt;
    -- Basic Latin small letters (not used in Classical Latin, but added in Medieval Latin)&lt;br /&gt;
    c = 100, -- = &amp;#039;C&amp;#039;.&lt;br /&gt;
    d = 500, -- = &amp;#039;D&amp;#039;. TODO: add Medieval &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations like &amp;quot;IƆ&amp;quot;&lt;br /&gt;
    i = 1, -- = &amp;#039;I&amp;#039;.&lt;br /&gt;
    j = 1, -- = &amp;#039;J&amp;#039; = &amp;#039;I&amp;#039;. Modern distinct form of the formerly unified Roman letter &amp;#039;I&amp;#039;&lt;br /&gt;
    l = 50, -- = &amp;#039;L&amp;#039;.&lt;br /&gt;
    m = 1000, -- = &amp;#039;M&amp;#039;.&lt;br /&gt;
    n = 0, -- = &amp;#039;N&amp;#039;. Abbreviated &amp;quot;nec&amp;quot; or &amp;quot;non&amp;quot; adverb in Classical Latin&lt;br /&gt;
    o = 0, -- = &amp;#039;O&amp;#039; == &amp;#039;N&amp;#039;.&lt;br /&gt;
    u = 5, -- = &amp;#039;U&amp;#039; = &amp;#039;V&amp;#039;. Modern distinct form of the formerly unified Roman letter &amp;#039;V&amp;#039;&lt;br /&gt;
    v = 5, -- = &amp;#039;V&amp;#039;.&lt;br /&gt;
    w = 10, -- = &amp;#039;W&amp;#039; = &amp;#039;VV&amp;#039; = &amp;#039;X&amp;#039;. Modern distinct form of the former Roman archaic digram &amp;#039;VV&amp;#039; used as a numeral before &amp;#039;X&amp;#039;&lt;br /&gt;
    x = 10, -- = &amp;#039;X&amp;#039;.&lt;br /&gt;
    y = 2, -- = &amp;#039;Y&amp;#039; = &amp;#039;IJ&amp;#039; = &amp;#039;II&amp;#039;. Uncommon ligature&lt;br /&gt;
    -- U+012A .. U+012B : LATIN LETTER I/i WITH COMBINING MACRON, canonically equivalent to &amp;quot;I&amp;quot; and U+0304&lt;br /&gt;
    [&amp;#039;Ī&amp;#039;] = 1000, [&amp;#039;ī&amp;#039;] = 1000,&lt;br /&gt;
    -- U+016A .. U+016B : LATIN LETTER U/u WITH COMBINING MACRON, canonically equivalent to &amp;quot;U&amp;quot; and U+0304, modern distinct form of the formerly unified Roman letter&lt;br /&gt;
    [&amp;#039;Ū&amp;#039;] = 5000, [&amp;#039;ū&amp;#039;] = 5000,&lt;br /&gt;
    -- U+026A : LATIN SMALL CAPITAL LETTER I&lt;br /&gt;
    [&amp;#039;ɪ&amp;#039;] = 1, -- = &amp;#039;I&amp;#039;&lt;br /&gt;
    -- U+029F : LATIN SMALL CAPITAL LETTER L&lt;br /&gt;
    [&amp;#039;ʟ&amp;#039;] = 50, -- = &amp;#039;L&amp;#039;&lt;br /&gt;
    -- U+0304 .. U+0305 : COMBINING MACRON/OVERLINE&lt;br /&gt;
    [&amp;#039;\204\132&amp;#039;] = -1000, -- (0xCC,0x84 in UTF-8) multiplier (thousand), MACRON (compatiblity)&lt;br /&gt;
    [&amp;#039;\204\133&amp;#039;] = -1000, -- (0xCC,0x85 in UTF-8) multiplier (thousand), OVERLINE (recommanded)&lt;br /&gt;
    -- U+033F : COMBINING DOUBLE OVERLINE&lt;br /&gt;
    [&amp;#039;\204\191&amp;#039;] = -1000000, -- (0xCC,0xBF in UTF-8) multiplier (million)&lt;br /&gt;
    -- U+1D04 : LATIN SMALL CAPITAL LETTER C&lt;br /&gt;
    [&amp;#039;ᴄ&amp;#039;] = 100, -- = &amp;#039;C&amp;#039;&lt;br /&gt;
    -- U+1D05 : LATIN SMALL CAPITAL LETTER D&lt;br /&gt;
    [&amp;#039;ᴅ&amp;#039;] = 500, -- = &amp;#039;D&amp;#039;&lt;br /&gt;
    -- U+1D0A : LATIN SMALL CAPITAL LETTER J&lt;br /&gt;
    [&amp;#039;ᴊ&amp;#039;] = 1, -- = &amp;#039;J&amp;#039; = &amp;#039;I&amp;#039;&lt;br /&gt;
    -- U+1D0D : LATIN SMALL CAPITAL LETTER M&lt;br /&gt;
    [&amp;#039;ᴍ&amp;#039;] = 1000, -- = &amp;#039;M&amp;#039;&lt;br /&gt;
    -- U+1D1C : LATIN SMALL CAPITAL LETTER U&lt;br /&gt;
    [&amp;#039;ᴜ&amp;#039;] = 5, --  = &amp;#039;U&amp;#039; = &amp;#039;V&amp;#039;&lt;br /&gt;
    -- U+1D20 : LATIN SMALL CAPITAL LETTER V&lt;br /&gt;
    [&amp;#039;ᴠ&amp;#039;] = 5, --  = &amp;#039;V&amp;#039;&lt;br /&gt;
    -- U+2160 .. U+216F : Roman capital digit symbols (compatibility, monospaced in CJK fonts)&lt;br /&gt;
    [&amp;#039;Ⅰ&amp;#039;] = 1, [&amp;#039;Ⅱ&amp;#039;] = 2, [&amp;#039;Ⅲ&amp;#039;] = 3, [&amp;#039;Ⅳ&amp;#039;] = 4, [&amp;#039;Ⅴ&amp;#039;] = 5, [&amp;#039;Ⅵ&amp;#039;] = 6,&lt;br /&gt;
    [&amp;#039;Ⅶ&amp;#039;] = 7, [&amp;#039;Ⅷ&amp;#039;] = 8, [&amp;#039;Ⅸ&amp;#039;] = 9, [&amp;#039;Ⅹ&amp;#039;] = 10, [&amp;#039;Ⅺ&amp;#039;] = 11, [&amp;#039;Ⅻ&amp;#039;] = 12,&lt;br /&gt;
    [&amp;#039;Ⅼ&amp;#039;] = 50, [&amp;#039;Ⅽ&amp;#039;] = 100, [&amp;#039;Ⅾ&amp;#039;] = 500, [&amp;#039;Ⅿ&amp;#039;] = 1000,&lt;br /&gt;
    -- U+2170 .. U+217F : Roman lowercase digit symbols (compatibility, monospaced in CJK fonts)&lt;br /&gt;
    [&amp;#039;ⅰ&amp;#039;] = 1, [&amp;#039;ⅱ&amp;#039;] = 2, [&amp;#039;ⅲ&amp;#039;] = 3, [&amp;#039;ⅳ&amp;#039;] = 4, [&amp;#039;ⅴ&amp;#039;] = 5, [&amp;#039;ⅵ&amp;#039;] = 6,&lt;br /&gt;
    [&amp;#039;ⅶ&amp;#039;] = 7, [&amp;#039;ⅷ&amp;#039;] = 8, [&amp;#039;ⅸ&amp;#039;] = 9, [&amp;#039;ⅹ&amp;#039;] = 10, [&amp;#039;ⅺ&amp;#039;] = 11, [&amp;#039;ⅻ&amp;#039;] = 12,&lt;br /&gt;
    [&amp;#039;ⅼ&amp;#039;] = 50, [&amp;#039;ⅽ&amp;#039;] = 100, [&amp;#039;ⅾ&amp;#039;] = 500, [&amp;#039;ⅿ&amp;#039;] = 1000,&lt;br /&gt;
    -- U+2180 .. U+2182 : Old Roman symbols (these have no case pairs)&lt;br /&gt;
    [&amp;#039;ↀ&amp;#039;] = 1000, -- = &amp;#039;I̅&amp;#039; = &amp;#039;M&amp;#039;. TODO: add Medieval &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations like &amp;quot;CIƆ&amp;quot;; do not confuse it with &amp;quot;CD&amp;quot; (400=500-100)&lt;br /&gt;
    [&amp;#039;ↁ&amp;#039;] = 5000, -- = &amp;#039;V̅&amp;#039;. TODO: add Medieval &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations like &amp;quot;DƆ&amp;quot; and &amp;quot;IƆƆ&amp;quot;&lt;br /&gt;
    [&amp;#039;ↂ&amp;#039;] = 10000, -- = &amp;#039;X̅&amp;#039;. TODO: add Medieval &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations like &amp;quot;CCIƆƆ&amp;quot;&lt;br /&gt;
    -- U+2183..U+2184 : ROMAN DIGIT (CAPITAL|LOWER) REVERSED C. TODO: add for &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations (and support &amp;quot;Ɔ&amp;quot; OPEN O as aliases)&lt;br /&gt;
    -- The reversed &amp;quot;C&amp;quot; is a trailing multiplier by 10 but if it is not paired by a leading &amp;quot;C&amp;quot;, the surrounded value will be divided by 2:&lt;br /&gt;
    -- * &amp;quot;I&amp;quot; = 1, but if followed by followed by &amp;quot;Ɔ&amp;quot;, it takes the value 100:&lt;br /&gt;
    -- * when followed by a first &amp;quot;Ɔ&amp;quot; it multiplies it by 10 giving 1000 (assuming &amp;quot;CIƆ&amp;quot;), but if not prefixed by a pairing &amp;quot;C&amp;quot;, gives 500 for &amp;quot;IƆ&amp;quot; = &amp;quot;D&amp;quot;.&lt;br /&gt;
    -- * when followed by a second &amp;quot;Ɔ&amp;quot; it multiplies it by 10 giving 1000 (assuming &amp;quot;CCIƆƆ&amp;quot;), but if not prefixed by a pairing &amp;quot;C&amp;quot;, gives 5000 for &amp;quot;IƆƆ&amp;quot; = &amp;quot;DƆ&amp;quot;.&lt;br /&gt;
    -- * for higher multiples, using overlines is highly preferred for noting multipliers by 1000.&lt;br /&gt;
    -- U+2185: ROMAN NUMERAL SIX LATE FORM&lt;br /&gt;
    [&amp;#039;ↅ&amp;#039;] = 6, -- = &amp;#039;L&amp;#039;&lt;br /&gt;
    -- U+2186: ROMAN NUMERAL FIFTY EARLY FORM (Borrowed in Latin in capital form, from Greek Final sigma, similar to &amp;quot;C&amp;quot; with a leg meaning &amp;quot;half&amp;quot;)&lt;br /&gt;
    [&amp;#039;ↆ&amp;#039;] = 50, -- = &amp;#039;VI&amp;#039; (overstriked letters)&lt;br /&gt;
    -- U+2187 .. U+2188: ROMAN NUMERAL (ONE HUNDRED|FIFTY) THOUSAND (Archaic, rarely supported in fonts)&lt;br /&gt;
    [&amp;#039;ↇ&amp;#039;] = 50000, -- = &amp;#039;L̅&amp;#039;. TODO: add Medieval &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations like &amp;quot;DƆƆ&amp;quot; and &amp;quot;IƆƆƆ&amp;quot;&lt;br /&gt;
    [&amp;#039;ↈ&amp;#039;] = 100000, -- = &amp;#039;C̅&amp;#039;. TODO: add Medieval &amp;quot;apostrophic/Claudian/lunate&amp;quot; notations like &amp;quot;CCCDƆƆ&amp;quot; and &amp;quot;CCCIƆƆƆ&amp;quot;&lt;br /&gt;
  -- TODO: map mathematical symbols (Latin letters in designated styles), enclosed Latin letters, CJK wide variants&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--[=================[&lt;br /&gt;
   Private functions&lt;br /&gt;
--]=================]&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
This function returns a string containing the input value formatted as a Roman numeral.&lt;br /&gt;
It works for non-negative integers lower than 5 billions (up to 4 999 999 999: this covers&lt;br /&gt;
all unsigned 32-bit integers), otherwise it returns the number formatted using Latin&lt;br /&gt;
digits. The result string will be an UTF-8-encoded plain-text alphabetic string.&lt;br /&gt;
]==]--&lt;br /&gt;
local function convertArabicToRoman(value)&lt;br /&gt;
    if value and  value &amp;gt;= 1 and value &amp;lt;= 4999999999 and value == math.floor(value) then&lt;br /&gt;
        local d0, d1, d2, d3, d4, d5, d6, d7, d8&lt;br /&gt;
        d0, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d1, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d2, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d3, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d4, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d5, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d6, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d7, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        d8, value = value % 10, math.floor(value / 10)&lt;br /&gt;
        return table.concat({&lt;br /&gt;
            decimalRomans.d9[value],&lt;br /&gt;
            decimalRomans.d8[d8],&lt;br /&gt;
            decimalRomans.d7[d7],&lt;br /&gt;
            decimalRomans.d6[d6],&lt;br /&gt;
            decimalRomans.d5[d5],&lt;br /&gt;
            decimalRomans.d4[d4],&lt;br /&gt;
            decimalRomans.d3[d3],&lt;br /&gt;
            decimalRomans.d2[d2],&lt;br /&gt;
            decimalRomans.d1[d1],&lt;br /&gt;
            decimalRomans.d0[d0],&lt;br /&gt;
        })&lt;br /&gt;
    elseif value == 0 then&lt;br /&gt;
        return &amp;#039;N&amp;#039; -- for adverbs &amp;quot;nec&amp;quot; or &amp;quot;non&amp;quot; in Classical Latin (which had no zero)&lt;br /&gt;
    end&lt;br /&gt;
    return tostring(value)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
This function converts a plain-text string containing a Roman numeral to an integer.&lt;br /&gt;
It works for values between 0 (N) and 4 999 999 999 (M̿M̿M̿M̿C̿M̿X̿C̿I̿X̿C̅M̅X̅C̅I̅X̅CMXCIX).&lt;br /&gt;
]==]--&lt;br /&gt;
local function convertRomanToArabic(roman)&lt;br /&gt;
    if roman == &amp;#039;&amp;#039; then return nil end&lt;br /&gt;
    local result, prevRomanDecimal, multiplier = 0, 0, 1&lt;br /&gt;
    for i = mw.ustring.len(roman), 1, -1 do&lt;br /&gt;
        local currentRomanDecimal = romanDecimals[mw.ustring.sub(roman, i, i)]&lt;br /&gt;
        if currentRomanDecimal == nil then&lt;br /&gt;
            return nil&lt;br /&gt;
        elseif currentRomanDecimal &amp;lt; 0 then&lt;br /&gt;
            multiplier = multiplier * -currentRomanDecimal&lt;br /&gt;
        else&lt;br /&gt;
            currentRomanDecimal, multiplier = currentRomanDecimal * multiplier, 1&lt;br /&gt;
            if currentRomanDecimal &amp;lt; prevRomanDecimal then&lt;br /&gt;
                result = result - currentRomanDecimal&lt;br /&gt;
            else&lt;br /&gt;
                result = result + currentRomanDecimal&lt;br /&gt;
                prevRomanDecimal = currentRomanDecimal&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
This function converts a string containing a Roman numeral to an integer.&lt;br /&gt;
It works for values between 0 and 4999999999.&lt;br /&gt;
The input string may contain HTML tags using style=&amp;quot;text-decoration:overline&amp;quot; (not recommended).&lt;br /&gt;
]==]--&lt;br /&gt;
local function convertRomanHTMLToArabic(roman)&lt;br /&gt;
    local result = convertRomanToArabic(roman)&lt;br /&gt;
    if result == nil then&lt;br /&gt;
        result = tonumber(roman)&lt;br /&gt;
    end&lt;br /&gt;
    return result&lt;br /&gt;
    [==[ DISABLED FOR NOW, NOT REALLY NEEDED AND NOT CORRECTLY TESTED&lt;br /&gt;
    local result = 0&lt;br /&gt;
    local overline_start_len = mw.ustring.len(overline_start)&lt;br /&gt;
    if mw.ustring.sub(roman, 1, overline_start_len) == overline_start then&lt;br /&gt;
        local end_tag_start, end_tag_end = mw.ustring.find(roman, overline_end, overline_start_len, true)&lt;br /&gt;
        if end_tag_start ~= nil then&lt;br /&gt;
            local roman_high = mw.ustring.sub(roman, overline_start_len + 1, end_tag_start - 1)&lt;br /&gt;
            local roman_low = mw.ustring.sub(roman, end_tag_end + 1, mw.ustring.len(roman)) or &amp;#039;&amp;#039;&lt;br /&gt;
            if (mw.ustring.find(roman_high, &amp;quot;^[mdclxvi]+$&amp;quot;) ~= nil) and (mw.ustring.find(roman_low, &amp;quot;^[mdclxvi]*$&amp;quot;) ~= nil) then&lt;br /&gt;
                result = convertRomanToArabic(roman_high) * 1000 + convertRomanToArabic(roman_low)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return result&lt;br /&gt;
    ]==]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Helper function to handle error messages.&lt;br /&gt;
]==]--&lt;br /&gt;
local function outputError(message)&lt;br /&gt;
    return table.concat({&lt;br /&gt;
        &amp;#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;Roman Module Error: &amp;#039;, message,&lt;br /&gt;
        &amp;#039;&amp;lt;/strong&amp;gt;[[Category:Errors reported by Module Roman]]&amp;#039;&lt;br /&gt;
    })&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[================[&lt;br /&gt;
   Public functions&lt;br /&gt;
--]================]&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
isRoman&lt;br /&gt;
&lt;br /&gt;
Tests if the trimmed input is a valid Roman numeral. Returns true if so, false if not.&lt;br /&gt;
For the purposes of this function, the empty string (after trimming whitespaces) is not a Roman numeral.&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
   s: string to test if it is a valid Roman numeral&lt;br /&gt;
&lt;br /&gt;
Error Handling:&lt;br /&gt;
   If the input is not a valid Roman numeral this function returns false.&lt;br /&gt;
]==]--&lt;br /&gt;
function p.isRoman(s)&lt;br /&gt;
    return type(s) == &amp;#039;string&amp;#039; and convertRomanToArabic(mw.text.trim(s)) ~= nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
toArabic&lt;br /&gt;
&lt;br /&gt;
This function converts a Roman numeral into an Arabic numeral.&lt;br /&gt;
It works for values between 0 and 4999999999.&lt;br /&gt;
&amp;#039;N&amp;#039; is converted to 0 and the empty string is converted to nil.&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
   roman: string containing value to convert into an Arabic numeral&lt;br /&gt;
&lt;br /&gt;
Error Handling:&lt;br /&gt;
   If the input is not a valid Roman numeral this function returns nil.&lt;br /&gt;
]==]--&lt;br /&gt;
function p.toArabic(roman)&lt;br /&gt;
    if type(roman) == &amp;#039;string&amp;#039; then&lt;br /&gt;
        roman = mw.text.trim(roman)&lt;br /&gt;
        local result = convertRomanToArabic(roman)&lt;br /&gt;
        if result == nil then&lt;br /&gt;
            result = tonumber(roman)&lt;br /&gt;
        end&lt;br /&gt;
        return result&lt;br /&gt;
    elseif type(roman) == &amp;#039;number&amp;#039; then&lt;br /&gt;
        return roman&lt;br /&gt;
    else&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
_Numeral&lt;br /&gt;
&lt;br /&gt;
This function returns a string containing the input value formatted as a Roman numeral.&lt;br /&gt;
It works for values between 0 and 4999999999.&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
   value: integer or string containing value to convert into a Roman numeral&lt;br /&gt;
&lt;br /&gt;
Error Handling:&lt;br /&gt;
   If the input does not look like it contains a number or the number is outside of the&lt;br /&gt;
   supported range an error message is returned.&lt;br /&gt;
]==]--&lt;br /&gt;
function p._Numeral(value)&lt;br /&gt;
    if value == nil then&lt;br /&gt;
        return outputError(&amp;#039;missing value&amp;#039;)&lt;br /&gt;
    end&lt;br /&gt;
    if type(value) == &amp;#039;string&amp;#039; then&lt;br /&gt;
        value = tonumber(value)&lt;br /&gt;
    elseif type(value) ~= &amp;#039;number&amp;#039; then&lt;br /&gt;
        return outputError(&amp;#039;unsupported value&amp;#039;)&lt;br /&gt;
    end&lt;br /&gt;
    return convertArabicToRoman(value)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Numeral&lt;br /&gt;
&lt;br /&gt;
This function for MediaWiki converts an Arabic numeral into a Roman numeral.&lt;br /&gt;
It works for values between 0 and 4999999999 (includes the whole range of unsigned 32-bit integers).&lt;br /&gt;
Arabic numeral zero is output as &amp;#039;N&amp;#039; (for Latin negation adverbs &amp;quot;nec&amp;quot; or &amp;quot;non&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
    {{#invoke:Roman|Numeral|&amp;lt;value&amp;gt;}}&lt;br /&gt;
    {{#invoke:Roman|Numeral}} - uses the caller&amp;#039;s parameters&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
    1: Value to convert into a Roman numeral. Must be at least 0 and less than 5,000,000.&lt;br /&gt;
&lt;br /&gt;
Error Handling:&lt;br /&gt;
    If the input does not look like it contains a number or the number is outside of the&lt;br /&gt;
    supported range an error message is returned.&lt;br /&gt;
]==]--&lt;br /&gt;
function p.Numeral(frame)&lt;br /&gt;
    -- if no argument provided than check parent template/module args&lt;br /&gt;
    local args = frame.args&lt;br /&gt;
    if args[1] == nil then&lt;br /&gt;
        args = frame:getParent().args&lt;br /&gt;
    end&lt;br /&gt;
    return p._Numeral(args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Jaider.ferreira</name></author>
	</entry>
</feed>