<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.schmino.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3AFormatNum</id>
	<title>Modul:FormatNum - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.schmino.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3AFormatNum"/>
	<link rel="alternate" type="text/html" href="https://wiki.schmino.de/index.php?title=Modul:FormatNum&amp;action=history"/>
	<updated>2026-08-06T14:51:47Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in KyllburgWiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.schmino.de/index.php?title=Modul:FormatNum&amp;diff=3347&amp;oldid=prev</id>
		<title>Dussy: Die Seite wurde neu angelegt: „-- 2013-06-16 FormatNum * format * round FormatNum()  local FormatNum = { };    -- Constant for round method &quot;round half to even&quot; (IEEE 754). local ROUND_T…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.schmino.de/index.php?title=Modul:FormatNum&amp;diff=3347&amp;oldid=prev"/>
		<updated>2016-05-05T08:17:04Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „--&lt;a href=&quot;/index.php?title=2013-06-16_FormatNum_*_format_*_round_FormatNum()&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;2013-06-16 FormatNum * format * round FormatNum() (Seite nicht vorhanden)&quot;&gt;2013-06-16 FormatNum * format * round FormatNum() &lt;/a&gt; local FormatNum = { };    -- Constant for round method &amp;quot;round half to even&amp;quot; (IEEE 754). local ROUND_T…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[ 2013-06-16&lt;br /&gt;
FormatNum&lt;br /&gt;
* format&lt;br /&gt;
* round&lt;br /&gt;
FormatNum()&lt;br /&gt;
]]&lt;br /&gt;
local FormatNum = { };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Constant for round method &amp;quot;round half to even&amp;quot; (IEEE 754).&lt;br /&gt;
local ROUND_TO_EVEN = 0;&lt;br /&gt;
&lt;br /&gt;
-- Constant for round method &amp;quot;round half away from zero&amp;quot;&lt;br /&gt;
-- (German: &amp;quot;kaufmaennisches Runden&amp;quot;),&lt;br /&gt;
-- also filters &amp;quot;-0&amp;quot; and converts it to &amp;quot;0&amp;quot;.&lt;br /&gt;
local ROUND_AWAY_FROM_ZERO = 1;&lt;br /&gt;
&lt;br /&gt;
-- Table storing the format options.&lt;br /&gt;
local FORMAT_TABLE = {};&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;de&amp;quot;.&lt;br /&gt;
FORMAT_TABLE.de = {};&lt;br /&gt;
FORMAT_TABLE.de.decimalMark = &amp;quot;,&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.de.groupMark = &amp;quot;&amp;amp;#x202F;&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.de.groupMinLength = 5;&lt;br /&gt;
FORMAT_TABLE.de.groupOnlyIntegerPart = false;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;de_currency&amp;quot;.&lt;br /&gt;
FORMAT_TABLE.de_currency = {};&lt;br /&gt;
FORMAT_TABLE.de_currency.decimalMark = &amp;quot;,&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.de_currency.groupMark = &amp;quot;.&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.de_currency.groupMinLength = 5;&lt;br /&gt;
FORMAT_TABLE.de_currency.groupOnlyIntegerPart = true;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;ch&amp;quot;.&lt;br /&gt;
FORMAT_TABLE.ch = {};&lt;br /&gt;
FORMAT_TABLE.ch.decimalMark = &amp;quot;,&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.ch.groupMark = &amp;quot;&amp;#039;&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.ch.groupMinLength = 5;&lt;br /&gt;
FORMAT_TABLE.ch.groupOnlyIntegerPart = true;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;en&amp;quot;.&lt;br /&gt;
FORMAT_TABLE.en = {};&lt;br /&gt;
FORMAT_TABLE.en.decimalMark = &amp;quot;.&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.en.groupMark = &amp;quot;,&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.en.groupMinLength = 4;&lt;br /&gt;
FORMAT_TABLE.en.groupOnlyIntegerPart = true;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;iso31_0&amp;quot; (ISO 31-0 using comma as decimal mark).&lt;br /&gt;
FORMAT_TABLE.iso31_0 = {};&lt;br /&gt;
FORMAT_TABLE.iso31_0.decimalMark = &amp;quot;,&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.iso31_0.groupMark = &amp;quot;&amp;amp;#x202F;&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.iso31_0.groupMinLength = 4;&lt;br /&gt;
FORMAT_TABLE.iso31_0.groupOnlyIntegerPart = false;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;iso31_0_point&amp;quot; (ISO 31-0 using point as decimal mark).&lt;br /&gt;
FORMAT_TABLE.iso31_0_point = {};&lt;br /&gt;
FORMAT_TABLE.iso31_0_point.decimalMark = &amp;quot;.&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.iso31_0_point.groupMark = &amp;quot;&amp;amp;#x202F;&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.iso31_0_point.groupMinLength = 4;&lt;br /&gt;
FORMAT_TABLE.iso31_0_point.groupOnlyIntegerPart = false;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;pc&amp;quot; (simply nil to prevent formatting).&lt;br /&gt;
FORMAT_TABLE.pc = nil;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;comma&amp;quot; (no grouping - groupMark &amp;quot;&amp;quot;).&lt;br /&gt;
FORMAT_TABLE.comma = {};&lt;br /&gt;
FORMAT_TABLE.comma.decimalMark = &amp;quot;,&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.comma.groupMark = &amp;quot;&amp;quot;;&lt;br /&gt;
FORMAT_TABLE.comma.groupMinLength = 1000; -- (for performance, but also small values wouldn&amp;#039;t matter)&lt;br /&gt;
FORMAT_TABLE.comma.groupOnlyIntegerPart = true;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;at&amp;quot; (only for convenience, same as &amp;quot;iso31_0&amp;quot;).&lt;br /&gt;
FORMAT_TABLE.at = FORMAT_TABLE.iso31_0;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;ch_currency&amp;quot; (only for convenience, same as &amp;quot;de_currency&amp;quot;).&lt;br /&gt;
FORMAT_TABLE.ch_currency = FORMAT_TABLE.de_currency;&lt;br /&gt;
&lt;br /&gt;
-- Format table for &amp;quot;dewiki&amp;quot; (only for convenience, same as &amp;quot;de_currency&amp;quot;).&lt;br /&gt;
FORMAT_TABLE.dewiki = FORMAT_TABLE.de_currency;&lt;br /&gt;
&lt;br /&gt;
-- Constant defining digit group lenghts when digit grouping is used.&lt;br /&gt;
local DIGIT_GROUPING_SIZE = 3;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
    Internal used function for rounding.&lt;br /&gt;
&lt;br /&gt;
    @param a_number : Number to be rounded.&lt;br /&gt;
    @param a_precision : Number of significant digits of the fractional part. If it&lt;br /&gt;
       is negative, the according number of digits of the integer part are also&lt;br /&gt;
       rounded.&lt;br /&gt;
    @param a_roundMethod : Numeric constant defining the round method to use.&lt;br /&gt;
       Supported are ROUND_TO_EVEN and ROUND_AWAY_FROM_ZERO.&lt;br /&gt;
&lt;br /&gt;
    @return String of the rounded number like returned by Lua function string.format().&lt;br /&gt;
]]&lt;br /&gt;
local function numberToString(a_number, a_precision, a_roundMethod)&lt;br /&gt;
    if (a_precision &amp;lt; 0) then&lt;br /&gt;
        a_precision = -a_precision;&lt;br /&gt;
        if (a_roundMethod == ROUND_TO_EVEN) then&lt;br /&gt;
            local integerPart = math.floor(math.abs(a_number) / (10 ^ a_precision));&lt;br /&gt;
            if (integerPart % 2 == 0) then&lt;br /&gt;
                -- next even number smaller than a_number / 10^precision&lt;br /&gt;
                a_number = a_number - 5 * (10 ^ (a_precision - 1));&lt;br /&gt;
                a_number = math.ceil(a_number / (10 ^ a_precision)) * (10 ^ a_precision);&lt;br /&gt;
            else&lt;br /&gt;
                -- next even number bigger than a_number / 10^precision&lt;br /&gt;
                a_number = a_number + 5 * (10 ^ (a_precision - 1));&lt;br /&gt;
                a_number = math.floor(a_number / (10 ^ a_precision)) * (10 ^ a_precision);&lt;br /&gt;
            end&lt;br /&gt;
        elseif (a_roundMethod == ROUND_AWAY_FROM_ZERO) then&lt;br /&gt;
            if (a_number &amp;gt;= 0) then&lt;br /&gt;
                a_number = a_number + 5 * (10 ^ (a_precision - 1));&lt;br /&gt;
                a_number = math.floor(a_number / (10 ^ a_precision)) * (10 ^ a_precision);&lt;br /&gt;
            else&lt;br /&gt;
                a_number = a_number - 5 * (10 ^ (a_precision - 1));&lt;br /&gt;
                a_number = math.ceil(a_number / (10 ^ a_precision)) * (10 ^ a_precision);&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        -- handle it as normal integer&lt;br /&gt;
        a_precision = 0;&lt;br /&gt;
    end&lt;br /&gt;
    if (a_roundMethod == ROUND_AWAY_FROM_ZERO) then&lt;br /&gt;
        if ((a_number * (10 ^ a_precision)) - math.floor(a_number * (10 ^ a_precision)) == 0.5) then&lt;br /&gt;
            -- because string.format() uses round to even, we have to add (numbers &amp;gt;0) or&lt;br /&gt;
            -- subtract (numbers &amp;lt;0) a little bit to point into the &amp;quot;correct&amp;quot; rounding&lt;br /&gt;
            -- direction if a_number is exactly in the middle between two rounded numbers&lt;br /&gt;
            if (a_number &amp;gt;= 0) then&lt;br /&gt;
                a_number = a_number + (10 ^ -(a_precision + 1));&lt;br /&gt;
            else&lt;br /&gt;
                a_number = a_number - (10 ^ -(a_precision + 1));&lt;br /&gt;
            end&lt;br /&gt;
        else&lt;br /&gt;
            if (math.abs(a_number * (10 ^ a_precision)) &amp;lt; 0.5) then&lt;br /&gt;
                -- filter &amp;quot;-0&amp;quot; and convert it to 0&lt;br /&gt;
                a_number = math.abs(a_number);&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return string.format(&amp;quot;%.&amp;quot; .. tostring(a_precision) .. &amp;quot;f&amp;quot;, a_number);&lt;br /&gt;
end -- numberToString()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
    Internal used function for formatting.&lt;br /&gt;
&lt;br /&gt;
    @param a_number : String of a non-negative number to be formatted.&lt;br /&gt;
    @param a_decimalMark : String of the decimal mark to use.&lt;br /&gt;
    @param a_groupMark : String of the mark used for digit grouping.&lt;br /&gt;
    @param a_groupMinLength : Number defining the minimum length of integer part&lt;br /&gt;
       to use digit grouping (normally 4 or 5). However if fractional part is&lt;br /&gt;
       longer than DIGIT_GROUPING_SIZE (3 as default) and digit grouping of&lt;br /&gt;
       fractional part is not disabled via &amp;#039;a_groupOnlyIntegerPart&amp;#039;, then this&lt;br /&gt;
       value is ignored and set to DIGIT_GROUPING_SIZE + 1.&lt;br /&gt;
    @param a_groupOnlyIntegerPart : Boolean defining whether activating digit&lt;br /&gt;
       grouping only for integer part (true) or for integer and fractional part&lt;br /&gt;
       (false).&lt;br /&gt;
&lt;br /&gt;
    @return String of the formatted number according to the parameters.&lt;br /&gt;
]]&lt;br /&gt;
local function formatNumber(a_number, a_decimalMark, a_groupMark, a_groupMinLength, a_groupOnlyIntegerPart)&lt;br /&gt;
    -- find the decimal point&lt;br /&gt;
    local decimalPosition = mw.ustring.find(a_number, &amp;quot;.&amp;quot;, 1, true);&lt;br /&gt;
    local needsGrouping = false;&lt;br /&gt;
    if (not decimalPosition) then&lt;br /&gt;
        -- no decimal point - integer number&lt;br /&gt;
        decimalPosition = mw.ustring.len(a_number) + 1;&lt;br /&gt;
        if (decimalPosition &amp;gt; a_groupMinLength) then&lt;br /&gt;
            needsGrouping = true;&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        -- decimal point present&lt;br /&gt;
        if ((decimalPosition &amp;gt; a_groupMinLength) or (((mw.ustring.len(a_number) - decimalPosition) &amp;gt; DIGIT_GROUPING_SIZE) and (not a_groupOnlyIntegerPart))) then&lt;br /&gt;
            needsGrouping = true;&lt;br /&gt;
        end&lt;br /&gt;
        -- replace the decimal point&lt;br /&gt;
        a_number = mw.ustring.sub(a_number, 1, decimalPosition - 1) .. a_decimalMark .. mw.ustring.sub(a_number, decimalPosition + 1);&lt;br /&gt;
    end&lt;br /&gt;
    if (needsGrouping and (decimalPosition &amp;gt; DIGIT_GROUPING_SIZE + 1)) then&lt;br /&gt;
        -- grouping of integer part necessary&lt;br /&gt;
        local i = decimalPosition - DIGIT_GROUPING_SIZE;&lt;br /&gt;
        while (i &amp;gt; 1) do&lt;br /&gt;
            -- group the integer part&lt;br /&gt;
            a_number = mw.ustring.sub(a_number, 1, i - 1) .. a_groupMark .. mw.ustring.sub(a_number, i);&lt;br /&gt;
            decimalPosition = decimalPosition + mw.ustring.len(a_groupMark);&lt;br /&gt;
            i = i - DIGIT_GROUPING_SIZE;&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    -- skip to the end of the new decimal mark (in case it is more than one char)&lt;br /&gt;
    decimalPosition = decimalPosition + mw.ustring.len(a_decimalMark) - 1;&lt;br /&gt;
    if (a_groupOnlyIntegerPart) then&lt;br /&gt;
        needsGrouping = false;&lt;br /&gt;
    end&lt;br /&gt;
    if (needsGrouping and ((mw.ustring.len(a_number) - decimalPosition) &amp;gt; DIGIT_GROUPING_SIZE)) then&lt;br /&gt;
        -- grouping of fractional part necessary&lt;br /&gt;
        -- using negative numbers (index from the end of the string)&lt;br /&gt;
        local i = decimalPosition - mw.ustring.len(a_number) + DIGIT_GROUPING_SIZE;&lt;br /&gt;
        while (i &amp;lt;= -1) do&lt;br /&gt;
            -- group the fractional part&lt;br /&gt;
            a_number = mw.ustring.sub(a_number, 1, i - 1) .. a_groupMark .. mw.ustring.sub(a_number, i);&lt;br /&gt;
            i = i + DIGIT_GROUPING_SIZE;&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return a_number;&lt;br /&gt;
end -- formatNumber()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
    Formatting numbers.&lt;br /&gt;
&lt;br /&gt;
    @param source : String representation&lt;br /&gt;
           of an unformatted (but maybe rounded) floating point or integer number.&lt;br /&gt;
    @param spec : Formatting option. Currently there are&lt;br /&gt;
           &amp;quot;at&amp;quot;, &amp;quot;comma&amp;quot;, &amp;quot;de&amp;quot;, &amp;quot;dewiki&amp;quot;, &amp;quot;de_currency&amp;quot;, &amp;quot;ch&amp;quot;, &amp;quot;ch_currency&amp;quot;, &amp;quot;en&amp;quot;, &amp;quot;iso31_0&amp;quot;,&lt;br /&gt;
           &amp;quot;iso31_0_point&amp;quot; and &amp;quot;pc&amp;quot; supported. See the FORMAT_TABLE for details.&lt;br /&gt;
&lt;br /&gt;
    @return String of the formatted number.&lt;br /&gt;
            If the argument &amp;#039;spec&amp;#039; is invalid&lt;br /&gt;
            or &amp;#039;source&amp;#039; is not a valid string representation of a number,&lt;br /&gt;
            &amp;#039;source&amp;#039; is returned unmodified.&lt;br /&gt;
]]&lt;br /&gt;
function FormatNum.format(source, spec)&lt;br /&gt;
    local number;&lt;br /&gt;
    if type(source) == &amp;quot;string&amp;quot; then&lt;br /&gt;
        number = mw.text.trim(source);&lt;br /&gt;
    end&lt;br /&gt;
    if not spec or spec == &amp;quot;&amp;quot; then&lt;br /&gt;
        spec = &amp;quot;dewiki&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if (number and spec) then&lt;br /&gt;
        local format = FORMAT_TABLE[spec];&lt;br /&gt;
        if (format) then&lt;br /&gt;
            -- format entry found&lt;br /&gt;
            local sign = mw.ustring.sub(number, 1, 1);&lt;br /&gt;
            if ((sign == &amp;quot;+&amp;quot;) or (sign == &amp;quot;-&amp;quot;)) then&lt;br /&gt;
                -- remove sign from number, add it later again&lt;br /&gt;
                number = mw.ustring.sub(number, 2);&lt;br /&gt;
            else&lt;br /&gt;
                -- was not a sign&lt;br /&gt;
                sign = &amp;quot;&amp;quot;;&lt;br /&gt;
            end&lt;br /&gt;
            if (mw.ustring.sub(number, 1, 1) == &amp;quot;.&amp;quot;) then&lt;br /&gt;
                -- number begins with &amp;quot;.&amp;quot; -&amp;gt; add a 0 to the beginning&lt;br /&gt;
                number = &amp;quot;0&amp;quot; .. number;&lt;br /&gt;
            else&lt;br /&gt;
                if (mw.ustring.sub(number, -1) == &amp;quot;.&amp;quot;) then&lt;br /&gt;
                    -- number ends with &amp;quot;.&amp;quot; -&amp;gt; remove it&lt;br /&gt;
                    number = mw.ustring.sub(number, 1, -2);&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
            if ((number == mw.ustring.match(number, &amp;quot;^%d+$&amp;quot;)) or (number == mw.ustring.match(number, &amp;quot;^%d+%.%d+$&amp;quot;))) then&lt;br /&gt;
                -- number has valid format (only digits or digits.digits) -&amp;gt; format it and add sign (if any) again&lt;br /&gt;
                number = sign .. formatNumber(number, format.decimalMark, format.groupMark, format.groupMinLength, format.groupOnlyIntegerPart);&lt;br /&gt;
            else&lt;br /&gt;
                -- number has no valid format -&amp;gt; undo all modifications&lt;br /&gt;
                number = source;&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return number;&lt;br /&gt;
end -- FormatNum.format()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
    Rounding numbers.&lt;br /&gt;
&lt;br /&gt;
    @param number : string with unformatted floating point or integer number.&lt;br /&gt;
    @param precision : number of significant fractional part digits.&lt;br /&gt;
           If precision is negative, the integer part is rounded as well.&lt;br /&gt;
    @param method : number defining the rounding method to use.&lt;br /&gt;
           Currently are supported only&lt;br /&gt;
              0 for &amp;#039;IEEE 754&amp;#039; rounding and&lt;br /&gt;
              1 for &amp;#039;round half away from zero&amp;#039;.&lt;br /&gt;
           If another number is supplied, the result is undefined.&lt;br /&gt;
&lt;br /&gt;
    @return String of the rounded number as returned by Lua function string.format().&lt;br /&gt;
            If one of the arguments is not a number, &amp;#039;number&amp;#039; is returned unmodified.&lt;br /&gt;
]]&lt;br /&gt;
function FormatNum.round(source, precision, method)&lt;br /&gt;
    local number = tonumber(source);&lt;br /&gt;
    if (number and precision and method) then&lt;br /&gt;
        return numberToString(number, math.floor(precision), math.floor(method));&lt;br /&gt;
    end&lt;br /&gt;
    return source;&lt;br /&gt;
end -- FormatNum.round()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local p = { };&lt;br /&gt;
&lt;br /&gt;
function p.format(frame)&lt;br /&gt;
    -- @param 1      : unformatted (but maybe rounded) floating point or integer number.&lt;br /&gt;
    -- @param number : same as 1 (DEPRECATED, backward compatibility).&lt;br /&gt;
    -- @param format : Formatting option. Currently there are&lt;br /&gt;
    --                 &amp;quot;at&amp;quot;, &amp;quot;comma&amp;quot;, &amp;quot;de&amp;quot;, &amp;quot;dewiki&amp;quot;, &amp;quot;de_currency&amp;quot;, &amp;quot;ch&amp;quot;, &amp;quot;ch_currency&amp;quot;,&lt;br /&gt;
    --                 &amp;quot;en&amp;quot;, &amp;quot;iso31_0&amp;quot;, &amp;quot;iso31_0_point&amp;quot; and &amp;quot;pc&amp;quot; supported.&lt;br /&gt;
    local source = frame.args[1];&lt;br /&gt;
    if (not source) then&lt;br /&gt;
        source = frame.args.number;    -- DEPRECATED&lt;br /&gt;
        pcall( require, &amp;quot;Module:FormatNumDEPRECATED&amp;quot; )&lt;br /&gt;
    end&lt;br /&gt;
    return FormatNum.format(source, frame.args.format)  or  &amp;quot;&amp;quot;;&lt;br /&gt;
end -- .format()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function p.round(frame)&lt;br /&gt;
    -- @param 1      : string with unformatted floating point or integer number.&lt;br /&gt;
    -- @param number : same as 1 (DEPRECATED, backward compatibility).&lt;br /&gt;
    -- @param precision : number of significant fractional part digits.&lt;br /&gt;
    --        If precision is negative, the integer part is rounded as well.&lt;br /&gt;
    -- @param method : number defining the rounding method to be used.&lt;br /&gt;
    --                 Currently are supported only&lt;br /&gt;
    --                    0 for &amp;#039;IEEE 754&amp;#039; rounding and&lt;br /&gt;
    --                    1 for &amp;#039;round half away from zero&amp;#039;.&lt;br /&gt;
    --                 If another number is supplied, the result is undefined.&lt;br /&gt;
    local precision = tonumber(frame.args.precision);&lt;br /&gt;
    local method = tonumber(frame.args.method);&lt;br /&gt;
    local source = frame.args[1];&lt;br /&gt;
    if (not source) then&lt;br /&gt;
        source = frame.args.number;    -- DEPRECATED&lt;br /&gt;
        pcall( require, &amp;quot;Module:FormatNumDEPRECATED&amp;quot; )&lt;br /&gt;
    end&lt;br /&gt;
    if (source and precision) then&lt;br /&gt;
        return FormatNum.round(source, precision, method);&lt;br /&gt;
    end&lt;br /&gt;
    return source or &amp;quot;&amp;quot;;&lt;br /&gt;
end -- .round()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Export access for Lua modules&lt;br /&gt;
function p.FormatNum()&lt;br /&gt;
    return FormatNum;&lt;br /&gt;
end -- .FormatNum()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- DEPRECATED&lt;br /&gt;
function p.formatNumber(frame)&lt;br /&gt;
    pcall( require, &amp;quot;Module:FormatNumDEPRECATED&amp;quot; )&lt;br /&gt;
    return p.format(frame);&lt;br /&gt;
end&lt;br /&gt;
function p.numberToString(frame)&lt;br /&gt;
    pcall( require, &amp;quot;Module:FormatNumDEPRECATED&amp;quot; )&lt;br /&gt;
    return p.round(frame);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p;&lt;/div&gt;</summary>
		<author><name>Dussy</name></author>
	</entry>
</feed>