<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ar">
	<id>https://www.copticpedia.org/index.php?action=history&amp;feed=atom&amp;title=%D9%88%D8%AD%D8%AF%D8%A9%3AConvertNumeric</id>
	<title>وحدة:ConvertNumeric - تاريخ المراجعة</title>
	<link rel="self" type="application/atom+xml" href="https://www.copticpedia.org/index.php?action=history&amp;feed=atom&amp;title=%D9%88%D8%AD%D8%AF%D8%A9%3AConvertNumeric"/>
	<link rel="alternate" type="text/html" href="https://www.copticpedia.org/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:ConvertNumeric&amp;action=history"/>
	<updated>2026-04-07T11:49:57Z</updated>
	<subtitle>تاريخ التعديل لهذه الصفحة في الويكي</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://www.copticpedia.org/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:ConvertNumeric&amp;diff=16677&amp;oldid=prev</id>
		<title>Gerges: ٢٤ مراجعة</title>
		<link rel="alternate" type="text/html" href="https://www.copticpedia.org/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:ConvertNumeric&amp;diff=16677&amp;oldid=prev"/>
		<updated>2021-03-21T22:59:12Z</updated>

		<summary type="html">&lt;p&gt;٢٤ مراجعة&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحة جديدة&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Module for converting between different representations of numbers. See talk page for user documentation.&lt;br /&gt;
-- For unit tests see: [[Module:ConvertNumeric/testcases]]&lt;br /&gt;
-- When editing, preview with: Module_talk:ConvertNumeric/testcases&lt;br /&gt;
-- First edit [[Module:ConvertNumeric/sandbox]] and preview with Module_talk:ConvertNumeric/sandbox/testcases&lt;br /&gt;
&lt;br /&gt;
local ones_position = {&lt;br /&gt;
	[0] = 'صفر',&lt;br /&gt;
	[1] = 'واحد',&lt;br /&gt;
	[2] = 'إثنان',&lt;br /&gt;
	[3] = 'ثلاثة',&lt;br /&gt;
	[4] = 'أربعة',&lt;br /&gt;
	[5] = 'خمسة',&lt;br /&gt;
	[6] = 'ستة',&lt;br /&gt;
	[7] = 'سبعة',&lt;br /&gt;
	[8] = 'ثمانية',&lt;br /&gt;
	[9] = 'تسعة',&lt;br /&gt;
	[10] = 'عشرة',&lt;br /&gt;
	[11] = 'إحدى عشر',&lt;br /&gt;
[12] = 'إثنى عشر',&lt;br /&gt;
	[13] = 'ثلاثة عشر',&lt;br /&gt;
	[14] = 'أربعة عشر',&lt;br /&gt;
	[15] = 'خمسةعشر',&lt;br /&gt;
	[16] = 'ستة عشر',&lt;br /&gt;
	[17] = 'سبعة عشر',&lt;br /&gt;
	[18] = 'ثمانية عشر',&lt;br /&gt;
	[19] = 'تسعة عشر'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local ones_position_ord = {&lt;br /&gt;
	[0] = 'صفري',&lt;br /&gt;
	[1] = 'أول',&lt;br /&gt;
	[2] = 'ثاني',&lt;br /&gt;
	[3] = 'ثالث',&lt;br /&gt;
	[4] = 'رابع',&lt;br /&gt;
	[5] = 'خامس',&lt;br /&gt;
	[6] = 'سادس',&lt;br /&gt;
	[7] = 'سابع',&lt;br /&gt;
	[8] = 'ثامن',&lt;br /&gt;
	[9] = 'تاسع',&lt;br /&gt;
	[10] = 'عاشر',&lt;br /&gt;
	[11] = 'حادي عشر',&lt;br /&gt;
	[12] = 'ثاني عشر',&lt;br /&gt;
	[13] = 'ثالث عشر',&lt;br /&gt;
	[14] = 'رابع عشر',&lt;br /&gt;
	[15] = 'خامس عشر',&lt;br /&gt;
	[16] = 'سادس عشر',&lt;br /&gt;
	[17] = 'سابع عشر',&lt;br /&gt;
	[18] = 'ثامن عشر',&lt;br /&gt;
	[19] = 'تاسع عشر'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local ones_position_plural = {&lt;br /&gt;
		[0] = 'صفرين',&lt;br /&gt;
	[1] = 'واحد',&lt;br /&gt;
	[2] = 'إثنان',&lt;br /&gt;
	[3] = 'ثلاثة',&lt;br /&gt;
	[4] = 'أربعة',&lt;br /&gt;
	[5] = 'خمسة',&lt;br /&gt;
	[6] = 'ستة',&lt;br /&gt;
	[7] = 'سبعة',&lt;br /&gt;
	[8] = 'ثمانية',&lt;br /&gt;
	[9] = 'تسعة',&lt;br /&gt;
	[10] = 'عشر',&lt;br /&gt;
	[11] = 'إحدى عشر',&lt;br /&gt;
	[12] = 'إثنى عشر',&lt;br /&gt;
	[13] = 'ثلاثة عشر',&lt;br /&gt;
	[14] = 'أربعة عشر',&lt;br /&gt;
	[15] = 'خمسة عشر',&lt;br /&gt;
	[16] = 'ستة عشر',&lt;br /&gt;
	[17] = 'سبعة عشر',&lt;br /&gt;
	[18] = 'ثمانية عشر',&lt;br /&gt;
	[19] = 'تسعة عشر'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local tens_position = {&lt;br /&gt;
	[2] = 'عشرون',&lt;br /&gt;
	[3] = 'ثلاثون',&lt;br /&gt;
	[4] = 'أربعون',&lt;br /&gt;
	[5] = 'خمسون',&lt;br /&gt;
	[6] = 'ستون',&lt;br /&gt;
	[7] = 'سبعون',&lt;br /&gt;
	[8] = 'ثمانون',&lt;br /&gt;
	[9] = 'تسعون'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local tens_position_ord = {&lt;br /&gt;
	[2] = 'عشرون',&lt;br /&gt;
	[3] = 'ثلاثون',&lt;br /&gt;
	[4] = 'أربعون',&lt;br /&gt;
	[5] = 'خمسون',&lt;br /&gt;
	[6] = 'ستون',&lt;br /&gt;
	[7] = 'سبعون',&lt;br /&gt;
	[8] = 'ثمانون',&lt;br /&gt;
	[9] = 'تسعون'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local tens_position_plural = {&lt;br /&gt;
	[2] = 'عشرون',&lt;br /&gt;
	[3] = 'ثلاثون',&lt;br /&gt;
	[4] = 'أربعون',&lt;br /&gt;
	[5] = 'خمسون',&lt;br /&gt;
	[6] = 'ستون',&lt;br /&gt;
	[7] = 'سبعون',&lt;br /&gt;
	[8] = 'ثمانون',&lt;br /&gt;
	[9] = 'تسعون'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local groups = {&lt;br /&gt;
		[1] = 'ألف',&lt;br /&gt;
	[2] = 'مليون',&lt;br /&gt;
	[3] = 'مليار',&lt;br /&gt;
	[4] = 'تريليون',&lt;br /&gt;
	[5] = 'كوادريليون',&lt;br /&gt;
	[6] = 'كوينتليون~',&lt;br /&gt;
	[7] = 'sextillion',&lt;br /&gt;
	[8] = 'septillion',&lt;br /&gt;
	[9] = 'octillion',&lt;br /&gt;
	[10] = 'nonillion',&lt;br /&gt;
	[11] = 'decillion',&lt;br /&gt;
	[12] = 'undecillion',&lt;br /&gt;
	[13] = 'duodecillion',&lt;br /&gt;
	[14] = 'tredecillion',&lt;br /&gt;
	[15] = 'quattuordecillion',&lt;br /&gt;
	[16] = 'quindecillion',&lt;br /&gt;
	[17] = 'sexdecillion',&lt;br /&gt;
	[18] = 'septendecillion',&lt;br /&gt;
	[19] = 'octodecillion',&lt;br /&gt;
	[20] = 'novemdecillion',&lt;br /&gt;
	[21] = 'vigintillion',&lt;br /&gt;
	[22] = 'unvigintillion',&lt;br /&gt;
	[23] = 'duovigintillion',&lt;br /&gt;
	[24] = 'tresvigintillion',&lt;br /&gt;
	[25] = 'quattuorvigintillion',&lt;br /&gt;
	[26] = 'quinquavigintillion',&lt;br /&gt;
	[27] = 'sesvigintillion',&lt;br /&gt;
	[28] = 'septemvigintillion',&lt;br /&gt;
	[29] = 'octovigintillion',&lt;br /&gt;
	[30] = 'novemvigintillion',&lt;br /&gt;
	[31] = 'trigintillion',&lt;br /&gt;
	[32] = 'untrigintillion',&lt;br /&gt;
	[33] = 'duotrigintillion',&lt;br /&gt;
	[34] = 'trestrigintillion',&lt;br /&gt;
	[35] = 'quattuortrigintillion',&lt;br /&gt;
	[36] = 'quinquatrigintillion',&lt;br /&gt;
	[37] = 'sestrigintillion',&lt;br /&gt;
	[38] = 'septentrigintillion',&lt;br /&gt;
	[39] = 'octotrigintillion',&lt;br /&gt;
	[40] = 'noventrigintillion',&lt;br /&gt;
	[41] = 'quadragintillion',&lt;br /&gt;
	[51] = 'quinquagintillion',&lt;br /&gt;
	[61] = 'sexagintillion',&lt;br /&gt;
	[71] = 'septuagintillion',&lt;br /&gt;
	[81] = 'octogintillion',&lt;br /&gt;
	[91] = 'nonagintillion',&lt;br /&gt;
	[101] = 'centillion',&lt;br /&gt;
	[102] = 'uncentillion',&lt;br /&gt;
	[103] = 'duocentillion',&lt;br /&gt;
	[104] = 'trescentillion',&lt;br /&gt;
	[111] = 'decicentillion',&lt;br /&gt;
	[112] = 'undecicentillion',&lt;br /&gt;
	[121] = 'viginticentillion',&lt;br /&gt;
	[122] = 'unviginticentillion',&lt;br /&gt;
	[131] = 'trigintacentillion',&lt;br /&gt;
	[141] = 'quadragintacentillion',&lt;br /&gt;
	[151] = 'quinquagintacentillion',&lt;br /&gt;
	[161] = 'sexagintacentillion',&lt;br /&gt;
	[171] = 'septuagintacentillion',&lt;br /&gt;
	[181] = 'octogintacentillion',&lt;br /&gt;
	[191] = 'nonagintacentillion',&lt;br /&gt;
	[201] = 'ducentillion',&lt;br /&gt;
	[301] = 'trecentillion',&lt;br /&gt;
	[401] = 'quadringentillion',&lt;br /&gt;
	[501] = 'quingentillion',&lt;br /&gt;
	[601] = 'sescentillion',&lt;br /&gt;
	[701] = 'septingentillion',&lt;br /&gt;
	[801] = 'octingentillion',&lt;br /&gt;
	[901] = 'nongentillion',&lt;br /&gt;
	[1001] = 'millinillion',&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local roman_numerals = {&lt;br /&gt;
	I = 1,&lt;br /&gt;
	V = 5,&lt;br /&gt;
	X = 10,&lt;br /&gt;
	L = 50,&lt;br /&gt;
	C = 100,&lt;br /&gt;
	D = 500,&lt;br /&gt;
	M = 1000&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Converts a given valid roman numeral (and some invalid roman numerals) to a number. Returns -1, errorstring on error&lt;br /&gt;
local function roman_to_numeral(roman)&lt;br /&gt;
	if type(roman) ~= &amp;quot;string&amp;quot; then return -1, &amp;quot;roman numeral not a string&amp;quot; end&lt;br /&gt;
	local rev = roman:reverse()&lt;br /&gt;
	local raising = true&lt;br /&gt;
	local last = 0&lt;br /&gt;
	local result = 0&lt;br /&gt;
	for i = 1, #rev do&lt;br /&gt;
		local c = rev:sub(i, i)&lt;br /&gt;
		local next = roman_numerals[c]&lt;br /&gt;
		if next == nil then return -1, &amp;quot;roman numeral contains illegal character &amp;quot; .. c end&lt;br /&gt;
		if next &amp;gt; last then&lt;br /&gt;
			result = result + next&lt;br /&gt;
			raising = true&lt;br /&gt;
		elseif next &amp;lt; last then&lt;br /&gt;
			result = result - next&lt;br /&gt;
			raising = false&lt;br /&gt;
		elseif raising then&lt;br /&gt;
			result = result + next&lt;br /&gt;
		else&lt;br /&gt;
			result = result - next&lt;br /&gt;
		end&lt;br /&gt;
		last = next&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Converts a given integer between 0 and 100 to Arabic text (e.g. 47 -&amp;gt; forty-seven)&lt;br /&gt;
local function numeral_to_arabic_less_100(num, ordinal, plural, zero)&lt;br /&gt;
	local terminal_ones, terminal_tens&lt;br /&gt;
	if ordinal then&lt;br /&gt;
		terminal_ones = ones_position_ord&lt;br /&gt;
		terminal_tens = tens_position_ord&lt;br /&gt;
	elseif plural then&lt;br /&gt;
		terminal_ones = ones_position_plural&lt;br /&gt;
		terminal_tens = tens_position_plural&lt;br /&gt;
	else&lt;br /&gt;
		terminal_ones = ones_position&lt;br /&gt;
		terminal_tens = tens_position&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if num == 0 and zero ~= nil then&lt;br /&gt;
		return zero&lt;br /&gt;
	elseif num &amp;lt; 20 then&lt;br /&gt;
		return terminal_ones[num]&lt;br /&gt;
	elseif num % 10 == 0 then&lt;br /&gt;
		return terminal_tens[num / 10]&lt;br /&gt;
	else&lt;br /&gt;
		return terminal_ones[num % 10] .. '     و    ' .. tens_position[math.floor(num / 10)]&lt;br /&gt;
&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function standard_suffix(ordinal, plural)&lt;br /&gt;
	if ordinal then return '' end&lt;br /&gt;
	if plural then return '' end -- s&lt;br /&gt;
	return ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Converts a given integer (in string form) between 0 and 1000 to Arabic text (e.g. 47 -&amp;gt; forty-seven)&lt;br /&gt;
local function numeral_to_arabic_less_1000(num, use_and, ordinal, plural, zero)&lt;br /&gt;
	num = tonumber(num)&lt;br /&gt;
	if num &amp;lt; 100 then&lt;br /&gt;
		return numeral_to_arabic_less_100(num, ordinal, plural, zero)&lt;br /&gt;
	elseif num % 100 == 0 then&lt;br /&gt;
		return ones_position[num/100] .. ' مئة' .. standard_suffix(ordinal, plural)&lt;br /&gt;
	else&lt;br /&gt;
		return ones_position[math.floor(num/100)] .. ' مئة ' .. (use_and and 'و ' or '') .. numeral_to_arabic_less_100(num % 100, ordinal, plural, zero)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Converts a number expressed as a string in scientific notation to a string in standard decimal notation&lt;br /&gt;
-- e.g. 1.23E5 -&amp;gt; 123000, 1.23E-5 = .0000123. Conversion is exact, no rounding is performed.&lt;br /&gt;
local function scientific_notation_to_decimal(num)&lt;br /&gt;
	local exponent, subs = num:gsub(&amp;quot;^%-?%d*%.?%d*%-?[Ee]([+%-]?%d+)$&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	if subs == 0 then return num end  -- Input not in scientific notation, just return unmodified&lt;br /&gt;
	exponent = tonumber(exponent)&lt;br /&gt;
&lt;br /&gt;
	local negative = num:find(&amp;quot;^%-&amp;quot;)&lt;br /&gt;
	local _, decimal_pos = num:find(&amp;quot;%.&amp;quot;)&lt;br /&gt;
	-- Mantissa will consist of all decimal digits with no decimal point&lt;br /&gt;
	local mantissa = num:gsub(&amp;quot;^%-?(%d*)%.?(%d*)%-?[Ee][+%-]?%d+$&amp;quot;, &amp;quot;%1%2&amp;quot;)&lt;br /&gt;
	if negative and decimal_pos then decimal_pos = decimal_pos - 1 end&lt;br /&gt;
	if not decimal_pos then decimal_pos = #mantissa + 1 end&lt;br /&gt;
	local prev_len = #num&lt;br /&gt;
&lt;br /&gt;
	-- Remove leading zeros unless decimal point is in first position&lt;br /&gt;
	while decimal_pos &amp;gt; 1 and mantissa:sub(1,1) == '0' do&lt;br /&gt;
		mantissa = mantissa:sub(2)&lt;br /&gt;
		decimal_pos = decimal_pos - 1&lt;br /&gt;
	end&lt;br /&gt;
	-- Shift decimal point right for exponent &amp;gt; 0&lt;br /&gt;
	while exponent &amp;gt; 0 do&lt;br /&gt;
		decimal_pos = decimal_pos + 1&lt;br /&gt;
		exponent = exponent - 1&lt;br /&gt;
		if decimal_pos &amp;gt; #mantissa + 1 then mantissa = mantissa .. '0' end&lt;br /&gt;
		-- Remove leading zeros unless decimal point is in first position&lt;br /&gt;
		while decimal_pos &amp;gt; 1 and mantissa:sub(1,1) == '0' do&lt;br /&gt;
			mantissa = mantissa:sub(2)&lt;br /&gt;
			decimal_pos = decimal_pos - 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Shift decimal point left for exponent &amp;lt; 0&lt;br /&gt;
	while exponent &amp;lt; 0 do&lt;br /&gt;
		if decimal_pos == 1 then&lt;br /&gt;
			mantissa = '0' .. mantissa&lt;br /&gt;
		else&lt;br /&gt;
			decimal_pos = decimal_pos - 1&lt;br /&gt;
		end&lt;br /&gt;
		exponent = exponent + 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Insert decimal point in correct position and return&lt;br /&gt;
	return (negative and '-' or '') .. mantissa:sub(1, decimal_pos - 1) .. '.' .. mantissa:sub(decimal_pos)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Rounds a number to the nearest integer (NOT USED)&lt;br /&gt;
local function round_num(x)&lt;br /&gt;
	if x%1 &amp;gt;= 0.5 then&lt;br /&gt;
		return math.ceil(x)&lt;br /&gt;
	else&lt;br /&gt;
		return math.floor(x)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Rounds a number to the nearest two-word number (round = up, down, or &amp;quot;on&amp;quot; for round to nearest)&lt;br /&gt;
-- Numbers with two digits before the decimal will be rounded to an integer as specified by round.&lt;br /&gt;
-- Larger numbers will be rounded to a number with only one nonzero digit in front and all other digits zero.&lt;br /&gt;
-- Negative sign is preserved and does not count towards word limit.&lt;br /&gt;
local function round_for_Arabic(num, round)&lt;br /&gt;
	-- If an integer with at most two digits, just return&lt;br /&gt;
	if num:find(&amp;quot;^%-?%d?%d%.?$&amp;quot;) then return num end&lt;br /&gt;
&lt;br /&gt;
	local negative = num:find(&amp;quot;^%-&amp;quot;)&lt;br /&gt;
	if negative then&lt;br /&gt;
		-- We're rounding magnitude so flip it&lt;br /&gt;
		if round == 'up' then round = 'down' elseif round == 'down' then round = 'up' end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If at most two digits before decimal, round to integer and return&lt;br /&gt;
	local _, _, small_int, trailing_digits, round_digit = num:find(&amp;quot;^%-?(%d?%d?)%.((%d)%d*)$&amp;quot;)&lt;br /&gt;
	if small_int then&lt;br /&gt;
		local small_int_len = #small_int&lt;br /&gt;
		if small_int == '' then small_int = '0' end&lt;br /&gt;
		if (round == 'up' and trailing_digits:find('[1-9]')) or (round == 'on' and tonumber(round_digit) &amp;gt;= 5) then&lt;br /&gt;
			small_int = tostring(tonumber(small_int) + 1)&lt;br /&gt;
		end&lt;br /&gt;
		return (negative and '-' or '') .. small_int&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- When rounding up, any number with &amp;gt; 1 nonzero digit will round up (e.g. 1000000.001 rounds up to 2000000)&lt;br /&gt;
	local nonzero_digits = 0&lt;br /&gt;
	for digit in num:gfind(&amp;quot;[1-9]&amp;quot;) do&lt;br /&gt;
		nonzero_digits = nonzero_digits + 1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	num = num:gsub(&amp;quot;%.%d*$&amp;quot;, &amp;quot;&amp;quot;) -- Remove decimal part&lt;br /&gt;
	-- Second digit used to determine which way to round lead digit&lt;br /&gt;
	local _, _, lead_digit, round_digit, round_digit_2, rest = num:find(&amp;quot;^%-?(%d)(%d)(%d)(%d*)$&amp;quot;)&lt;br /&gt;
	if tonumber(lead_digit .. round_digit) &amp;lt; 20 and (1 + #rest) % 3 == 0 then&lt;br /&gt;
		-- In Arabic numbers &amp;lt; 20 are one word so put 2 digits in lead and round based on 3rd&lt;br /&gt;
		lead_digit = lead_digit .. round_digit&lt;br /&gt;
		round_digit = round_digit_2&lt;br /&gt;
	else&lt;br /&gt;
		rest = round_digit_2 .. rest&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (round == 'up' and nonzero_digits &amp;gt; 1) or (round == 'on' and tonumber(round_digit) &amp;gt;= 5) then&lt;br /&gt;
		lead_digit = tostring(tonumber(lead_digit) + 1)&lt;br /&gt;
	end&lt;br /&gt;
	-- All digits but lead digit will turn to zero&lt;br /&gt;
	rest = rest:gsub(&amp;quot;%d&amp;quot;, &amp;quot;0&amp;quot;)&lt;br /&gt;
	return (negative and '-' or '') .. lead_digit .. '0' .. rest&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local denominators = {&lt;br /&gt;
	[2] = { 'half', plural = 'halves' },&lt;br /&gt;
	[3] = { 'third' },&lt;br /&gt;
	[4] = { 'quarter', us = 'fourth' },&lt;br /&gt;
	[5] = { 'fifth' },&lt;br /&gt;
	[6] = { 'sixth' },&lt;br /&gt;
	[8] = { 'eighth' },&lt;br /&gt;
	[9] = { 'ninth' },&lt;br /&gt;
	[10] = { 'tenth' },&lt;br /&gt;
	[16] = { 'sixteenth' },&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Return status, fraction where:&lt;br /&gt;
-- status is a string:&lt;br /&gt;
--     &amp;quot;finished&amp;quot; if there is a fraction with no whole number;&lt;br /&gt;
--     &amp;quot;ok&amp;quot; if fraction is empty or valid;&lt;br /&gt;
--     &amp;quot;unsupported&amp;quot; if bad fraction;&lt;br /&gt;
-- fraction is a string giving (numerator / denominator) as Arabic text, or is &amp;quot;&amp;quot;.&lt;br /&gt;
-- Only unsigned fractions with a very limited range of values are supported,&lt;br /&gt;
-- except that if whole is empty, the numerator can use &amp;quot;-&amp;quot; to indicate negative.&lt;br /&gt;
-- whole (string or nil): nil or &amp;quot;&amp;quot; if no number before the fraction&lt;br /&gt;
-- numerator (string or nil): numerator, if any (default = 1 if a denominator is given)&lt;br /&gt;
-- denominator (string or nil): denominator, if any&lt;br /&gt;
-- sp_us (boolean): true if sp=us&lt;br /&gt;
-- negative_word (string): word to use for negative sign, if whole is empty&lt;br /&gt;
-- use_one (boolean): false: 2+1/2 → &amp;quot;two and a half&amp;quot;; true: &amp;quot;two and one-half&amp;quot;&lt;br /&gt;
local function fraction_to_Arabic(whole, numerator, denominator, sp_us, negative_word, use_one)&lt;br /&gt;
	if numerator or denominator then&lt;br /&gt;
		local finished = (whole == nil or whole == '')&lt;br /&gt;
		local sign = ''&lt;br /&gt;
		if numerator then&lt;br /&gt;
			if finished and numerator:sub(1, 1) == '-' then&lt;br /&gt;
				numerator = numerator:sub(2)&lt;br /&gt;
				sign = negative_word .. ' '&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			numerator = '1'&lt;br /&gt;
		end&lt;br /&gt;
		if not numerator:match('^%d+$') or not denominator or not denominator:match('^%d+$') then&lt;br /&gt;
			return 'unsupported', ''&lt;br /&gt;
		end&lt;br /&gt;
		numerator = tonumber(numerator)&lt;br /&gt;
		denominator = tonumber(denominator)&lt;br /&gt;
		local dendata = denominators[denominator]&lt;br /&gt;
		if not (dendata and 1 &amp;lt;= numerator and numerator &amp;lt;= 99) then&lt;br /&gt;
			return 'unsupported', ''&lt;br /&gt;
		end&lt;br /&gt;
		local numstr, denstr&lt;br /&gt;
		local sep = '-'&lt;br /&gt;
		if numerator == 1 then&lt;br /&gt;
			denstr = sp_us and dendata.us or dendata[1]&lt;br /&gt;
			if finished or use_one then&lt;br /&gt;
				numstr = 'one'&lt;br /&gt;
			elseif denstr:match('^[aeiou]') then&lt;br /&gt;
				numstr = 'an'&lt;br /&gt;
				sep = ' '&lt;br /&gt;
			else&lt;br /&gt;
				numstr = 'a'&lt;br /&gt;
				sep = ' '&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			numstr = numeral_to_arabic_less_100(numerator)&lt;br /&gt;
			denstr = dendata.plural&lt;br /&gt;
			if not denstr then&lt;br /&gt;
				denstr = (sp_us and dendata.us or dendata[1]) .. 's'&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if finished then&lt;br /&gt;
			return 'finished', sign .. numstr .. sep .. denstr&lt;br /&gt;
		end&lt;br /&gt;
		return 'ok', ' and ' .. numstr .. sep .. denstr&lt;br /&gt;
	end&lt;br /&gt;
	return 'ok', ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Takes a decimal number and converts it to Arabic text.&lt;br /&gt;
-- Return nil if a fraction cannot be converted (only some numbers are supported for fractions).&lt;br /&gt;
-- num (string or nil): the number to convert.&lt;br /&gt;
--      Can be an arbitrarily large decimal, such as &amp;quot;-123456789123456789.345&amp;quot;, and&lt;br /&gt;
--      can use scientific notation (e.g. &amp;quot;1.23E5&amp;quot;).&lt;br /&gt;
--      May fail for very large numbers not listed in &amp;quot;groups&amp;quot; such as &amp;quot;1E4000&amp;quot;.&lt;br /&gt;
--      num is nil if there is no whole number before a fraction.&lt;br /&gt;
-- numerator (string or nil): numerator of fraction (nil if no fraction)&lt;br /&gt;
-- denominator (string or nil): denominator of fraction (nil if no fraction)&lt;br /&gt;
-- capitalize (boolean): whether to capitalize the result (e.g. 'One' instead of 'one')&lt;br /&gt;
-- use_and (boolean): whether to use the word 'and' between tens/ones place and higher places&lt;br /&gt;
-- hyphenate (boolean): whether to hyphenate all words in the result, useful for use as an adjective&lt;br /&gt;
-- ordinal (boolean): whether to produce an ordinal (e.g. 'first' instead of 'one')&lt;br /&gt;
-- plural (boolean): whether to pluralize the resulting number&lt;br /&gt;
-- links: nil: do not add any links; 'on': link &amp;quot;billion&amp;quot; and larger to Orders of magnitude article;&lt;br /&gt;
--        any other text: list of numbers to link (e.g. &amp;quot;billion,quadrillion&amp;quot;)&lt;br /&gt;
-- negative_word: word to use for negative sign (typically 'negative' or 'minus'; nil to use default)&lt;br /&gt;
-- round: nil or '': no rounding; 'on': round to nearest two-word number; 'up'/'down': round up/down to two-word number&lt;br /&gt;
-- zero: word to use for value '0' (nil to use default)&lt;br /&gt;
-- use_one (boolean): false: 2+1/2 → &amp;quot;two and a half&amp;quot;; true: &amp;quot;two and one-half&amp;quot;&lt;br /&gt;
local function _numeral_to_arabic(num, numerator, denominator, capitalize, use_and, hyphenate, ordinal, plural, links, negative_word, round, zero, use_one)&lt;br /&gt;
	if not negative_word then&lt;br /&gt;
		if use_and then&lt;br /&gt;
			-- TODO Should 'minus' be used when do not have sp=us?&lt;br /&gt;
			--      If so, need to update testcases, and need to fix &amp;quot;minus zero&amp;quot;.&lt;br /&gt;
			-- negative_word = 'minus'&lt;br /&gt;
			negative_word = 'negative'&lt;br /&gt;
		else&lt;br /&gt;
			negative_word = 'negative'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local status, fraction_text = fraction_to_Arabic(num, numerator, denominator, not use_and, negative_word, use_one)&lt;br /&gt;
	if status == 'unsupported' then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if status == 'finished' then&lt;br /&gt;
		-- Input is a fraction with no whole number.&lt;br /&gt;
		-- Hack to avoid executing stuff that depends on num being a number.&lt;br /&gt;
		local s = fraction_text&lt;br /&gt;
		if hyphenate then s = s:gsub(&amp;quot;%s&amp;quot;, &amp;quot;-&amp;quot;) end&lt;br /&gt;
		if capitalize then s = s:gsub(&amp;quot;^%l&amp;quot;, string.upper) end&lt;br /&gt;
		return s&lt;br /&gt;
	end&lt;br /&gt;
	num = scientific_notation_to_decimal(num)&lt;br /&gt;
	if round and round ~= '' then&lt;br /&gt;
		if round ~= 'on' and round ~= 'up' and round ~= 'down' then&lt;br /&gt;
			error(&amp;quot;Invalid rounding mode&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		num = round_for_Arabic(num, round)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Separate into negative sign, num (digits before decimal), decimal_places (digits after decimal)&lt;br /&gt;
	local MINUS = '−'  -- Unicode U+2212 MINUS SIGN (may be in values from [[Module:Convert]])&lt;br /&gt;
	if num:sub(1, #MINUS) == MINUS then&lt;br /&gt;
		num = '-' .. num:sub(#MINUS + 1)  -- replace MINUS with '-'&lt;br /&gt;
	elseif num:sub(1, 1) == '+' then&lt;br /&gt;
		num = num:sub(2)  -- ignore any '+'&lt;br /&gt;
	end&lt;br /&gt;
	local negative = num:find(&amp;quot;^%-&amp;quot;)&lt;br /&gt;
	local decimal_places, subs = num:gsub(&amp;quot;^%-?%d*%.(%d+)$&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	if subs == 0 then decimal_places = nil end&lt;br /&gt;
	num, subs = num:gsub(&amp;quot;^%-?(%d*)%.?%d*$&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	if num == '' and decimal_places then num = '0' end&lt;br /&gt;
	if subs == 0 or num == '' then error(&amp;quot;Invalid decimal numeral&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
	-- For each group of 3 digits except the last one, print with appropriate group name (e.g. million)&lt;br /&gt;
	local s = ''&lt;br /&gt;
	while #num &amp;gt; 3 do&lt;br /&gt;
		if s ~= '' then s = s .. ' ' end&lt;br /&gt;
		local group_num = math.floor((#num - 1) / 3)&lt;br /&gt;
		local group = groups[group_num]&lt;br /&gt;
		local group_digits = #num - group_num*3&lt;br /&gt;
		s = s .. numeral_to_arabic_less_1000(num:sub(1, group_digits), false, false, false, zero) .. ' '&lt;br /&gt;
		if links and (((links == 'on' and group_num &amp;gt;= 3) or links:find(group)) and group_num &amp;lt;= 13) then&lt;br /&gt;
			s = s .. '[[Orders_of_magnitude_(numbers)#10' .. group_num*3 .. '|' .. group .. ']]'&lt;br /&gt;
		else&lt;br /&gt;
			s = s .. group&lt;br /&gt;
		end&lt;br /&gt;
		num = num:sub(1 + group_digits)&lt;br /&gt;
		num = num:gsub(&amp;quot;^0*&amp;quot;, &amp;quot;&amp;quot;)  -- Trim leading zeros&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Handle final three digits of integer part&lt;br /&gt;
	if s ~= '' and num ~= '' then&lt;br /&gt;
		if #num &amp;lt;= 2 and use_and then&lt;br /&gt;
			s = s .. ' and '&lt;br /&gt;
		else&lt;br /&gt;
			s = s .. ' '&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if s == '' or num ~= '' then&lt;br /&gt;
		s = s .. numeral_to_arabic_less_1000(num, use_and, ordinal, plural, zero)&lt;br /&gt;
	elseif ordinal or plural then&lt;br /&gt;
		-- Round numbers like &amp;quot;one million&amp;quot; take standard suffixes for ordinal/plural&lt;br /&gt;
		s = s .. standard_suffix(ordinal, plural)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- For decimal places (if any) output &amp;quot;point&amp;quot; followed by spelling out digit by digit&lt;br /&gt;
	if decimal_places then&lt;br /&gt;
		s = s .. ' point'&lt;br /&gt;
		for i = 1, #decimal_places do&lt;br /&gt;
			s = s .. ' ' .. ones_position[tonumber(decimal_places:sub(i,i))]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	s = s:gsub(&amp;quot;^%s*(.-)%s*$&amp;quot;, &amp;quot;%1&amp;quot;)   -- Trim whitespace&lt;br /&gt;
	if ordinal and plural then s = s .. 's' end  -- s suffix works for all ordinals&lt;br /&gt;
	if negative and s ~= zero then s = negative_word .. ' ' .. s end&lt;br /&gt;
	s = s:gsub(&amp;quot;negative zero&amp;quot;, &amp;quot;zero&amp;quot;)&lt;br /&gt;
	s = s .. fraction_text&lt;br /&gt;
	if hyphenate then s = s:gsub(&amp;quot;%s&amp;quot;, &amp;quot;-&amp;quot;) end&lt;br /&gt;
	if capitalize then s = s:gsub(&amp;quot;^%l&amp;quot;, string.upper) end&lt;br /&gt;
	return s&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local p = {  -- functions that can be called from another module&lt;br /&gt;
	roman_to_numeral = roman_to_numeral,&lt;br /&gt;
	spell_number = _numeral_to_arabic,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.numeral_to_arabic(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	local num = args[1]&lt;br /&gt;
	num = num:gsub(&amp;quot;^%s*(.-)%s*$&amp;quot;, &amp;quot;%1&amp;quot;)   -- Trim whitespace&lt;br /&gt;
	num = num:gsub(&amp;quot;,&amp;quot;, &amp;quot;&amp;quot;)   -- Remove commas&lt;br /&gt;
	if num ~= '' then  -- a fraction may have an empty whole number&lt;br /&gt;
		if not num:find(&amp;quot;^%-?%d*%.?%d*%-?[Ee]?[+%-]?%d*$&amp;quot;) then&lt;br /&gt;
			-- Input not in a valid format, try to pass it through #expr to see&lt;br /&gt;
			-- if that produces a number (e.g. &amp;quot;3 + 5&amp;quot; will become &amp;quot;8&amp;quot;).&lt;br /&gt;
			num = frame:preprocess('{{#expr: ' .. num .. '}}')&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Pass args from frame to helper function&lt;br /&gt;
	return _numeral_to_arabic(&lt;br /&gt;
		num,&lt;br /&gt;
		args['numerator'],&lt;br /&gt;
		args['denominator'],&lt;br /&gt;
		args['case'] == 'U' or args['case'] == 'u',&lt;br /&gt;
		args['sp'] ~= 'us',&lt;br /&gt;
		args['adj'] == 'on',&lt;br /&gt;
		args['ord'] == 'on',&lt;br /&gt;
		args['pl'] == 'on',&lt;br /&gt;
		args['lk'],&lt;br /&gt;
		args['negative'],&lt;br /&gt;
		args['round'],&lt;br /&gt;
		args['zero'],&lt;br /&gt;
		args['one'] == 'one'  -- experiment: using '|one=one' makes fraction 2+1/2 give &amp;quot;two and one-half&amp;quot; instead of &amp;quot;two and a half&amp;quot;&lt;br /&gt;
	) or ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
---- recursive function for p.decToHex&lt;br /&gt;
local function decToHexDigit(dec)&lt;br /&gt;
	local dig = {&amp;quot;0&amp;quot;,&amp;quot;1&amp;quot;,&amp;quot;2&amp;quot;,&amp;quot;3&amp;quot;,&amp;quot;4&amp;quot;,&amp;quot;5&amp;quot;,&amp;quot;6&amp;quot;,&amp;quot;7&amp;quot;,&amp;quot;8&amp;quot;,&amp;quot;9&amp;quot;,&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;,&amp;quot;C&amp;quot;,&amp;quot;D&amp;quot;,&amp;quot;E&amp;quot;,&amp;quot;F&amp;quot;}&lt;br /&gt;
	local div = math.floor(dec/16)&lt;br /&gt;
	local mod = dec-(16*div)&lt;br /&gt;
	if div &amp;gt;= 1 then return decToHexDigit(div)..dig[mod+1] else return dig[mod+1] end&lt;br /&gt;
end -- I think this is supposed to be done with a tail call but first I want something that works at all&lt;br /&gt;
---- finds all the decimal numbers in the input text and hexes each of them&lt;br /&gt;
function p.decToHex(frame)&lt;br /&gt;
	local args=frame.args&lt;br /&gt;
	local parent=frame.getParent(frame)&lt;br /&gt;
	local pargs={}&lt;br /&gt;
	if parent then pargs=parent.args end&lt;br /&gt;
	local text=args[1] or pargs[1] or &amp;quot;&amp;quot;&lt;br /&gt;
	local minlength=args.minlength or pargs.minlength or 1&lt;br /&gt;
	minlength=tonumber(minlength)&lt;br /&gt;
	local prowl=mw.ustring.gmatch(text,&amp;quot;(.-)(%d+)&amp;quot;)&lt;br /&gt;
	local output=&amp;quot;&amp;quot;&lt;br /&gt;
	repeat&lt;br /&gt;
		local chaff,dec=prowl()&lt;br /&gt;
		if not(dec) then break end&lt;br /&gt;
		local hex=decToHexDigit(dec)&lt;br /&gt;
		while (mw.ustring.len(hex)&amp;lt;minlength) do hex=&amp;quot;0&amp;quot;..hex end&lt;br /&gt;
		output=output..chaff..hex&lt;br /&gt;
	until false&lt;br /&gt;
	local chaff=mw.ustring.match(text,&amp;quot;(%D+)$&amp;quot;) or &amp;quot;&amp;quot;&lt;br /&gt;
	return output..chaff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Gerges</name></author>
	</entry>
</feed>