From Unofficial Rhythm Doctor Custom Level Wiki
This is the documentation page for Module:Formatnum
This module provides a number formatting function. This function can be used from #invoke or from other Lua modules.
This module is used by Module:Complex date
To use the module from normal wiki pages, no special preparation is needed. If you are using the module from another Lua module, first you need to load it, like this:
<syntaxhighlight lang="lua">
local mf = require('Module:Formatnum')
</syntaxhighlight>
(The mf variable stands for M odule F ormatnum; you can choose something more descriptive if you prefer.)
Most functions in the module have a version for Lua and a version for #invoke. It is possible to use the #invoke functions from other Lua modules, but using the Lua functions has the advantage that you do not need to access a Lua frame object . Lua functions are preceded by _, whereas #invoke functions are not.
{{#invoke:Formatnum|main|x |lang= |prec= |sep= }}
<syntaxhighlight lang="lua">
mf.formatNum(x, lang, prec, sep)
</syntaxhighlight>
Math templates
Functions
Numeral systems
Functions
{{#if:{{#ifeq:elementary arithmetic%|elementary arithmetic%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| elementary arithmetic
}}
{{#if:{{#ifeq:precision%|precision%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| precision
}}
{{#if:{{#ifeq:val%|val%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| val
}} (value formatting)
{{#if:{{#ifeq:percentage%|percentage%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| percentage
}}
Numeral systems
| [[Template:{{{2}}}|{{{2}}} ]]
| binary
}}
{{#if:{{#ifeq:decimal2Base%|decimal2Base%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| decimal2Base
}}
{{#if:{{#ifeq:hex2dec%|hex2dec%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| hex2dec
}}
{{#if:{{#ifeq:hexadecimal%|hexadecimal%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| hexadecimal
}}
{{#if:{{#ifeq:octal%|octal%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| octal
}}
{{#if:{{#ifeq:quaternary%|quaternary%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| quaternary
}}
{{#if:{{#ifeq:rn%|rn%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| rn
}}
{{#if:{{#ifeq:roman%|roman%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| roman
}}
{{#if:{{#ifeq:ternary%|ternary%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| ternary
}}
{{#if:{{#ifeq:vigesimal%|vigesimal%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| vigesimal
}}
Conversions
{{#if:{{#ifeq:convert%|convert%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| convert
}} many units (see: list ) {{#if:{{#ifeq:cvt%|cvt%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| cvt
}} abbreviated {{ convert }} {{#if:{{#ifeq:convinfobox%|convinfobox%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| convinfobox
}} {{ convert }} for infoboxes {{#if:{{#ifeq:bbl to t%|bbl to t%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| bbl to t
}} barrels of oil to tonnes {{#if:{{#ifeq:long ton%|long ton%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| long ton
}} long hundredweights, quarters and pounds to kilograms; long tons and hundredweights to pounds and metric tons {{#if:{{#ifeq:miles-chains%|miles-chains%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| miles-chains
}} miles and chains to kilometres linking "chains"
{{#if:{{#ifeq:decdeg%|decdeg%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| decdeg
}} degrees, minutes, and seconds to decimal degrees {{#if:{{#ifeq:deg2DMS%|deg2DMS%||yes}}
| deg2dms
| deg2dms
}} decimal degrees to degrees, minutes, and seconds {{#if:{{#ifeq:deg2HMS%|deg2HMS%||yes}}
| deg2hms
| deg2hms
}} decimal degrees to hour angle (in hours, minutes, and seconds) {{#if:{{#ifeq:HMS2Deg%|HMS2Deg%||yes}}
| hms2deg
| hms2deg
}} hour angle (in hours, minutes, and seconds) to decimal degrees {{#if:{{#ifeq:inflation%|inflation%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| inflation
}} calculate inflation of Consumer Price Index-related prices {{#if:{{#ifeq:pop density%|pop density%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| pop density
}} population density in an area {{#if:{{#ifeq:track gauge%|track gauge%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| track gauge
}} railway track gauges
{{#if:{{#ifeq:bigmath%|bigmath%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| bigmath
}} bigger font to match TeX \displaystyle (standalone formulas only) {{#if:{{#ifeq:math%|math%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| math
}} short text-based formulas {{#if:{{#ifeq:mathcal%|mathcal%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| mathcal
}} [mathematical] calligraphic font; alternative to LaTeX \mathcal{...} {{#if:{{#ifeq:tombstone%|tombstone%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| tombstone
}} symbol indicating the end of a proof {{#if:{{#ifeq:mvar%|mvar%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| mvar
}} individual italicized maths variables in normal text {{#if:{{#ifeq:val%|val%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| val
}} measurement values, uncertainties and units
{{#if:{{#ifeq:overline%|overline%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| overline
}}
{{#if:{{#ifeq:underline%|underline%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| underline
}} a line set above/below a sequence of characters {{#if:{{#ifeq:vec%|vec%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| vec
}} various overarrows, underarrows, etc. {{#if:{{#ifeq:abs%|abs%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| abs
}} absolute values (paired vertical lines)
{{#if:{{#ifeq:langle%|langle%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| langle
}}
{{#if:{{#ifeq:rangle%|rangle%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| rangle
}}
{{#if:{{#ifeq:Angle bracket%|Angle bracket%||yes}}
| angbr
| angbr
}} angular brackets
{{#if:{{#ifeq:bra-ket%|bra-ket%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| bra-ket
}}
{{#if:{{#ifeq:braket%|braket%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| braket
}}
{{#if:{{#ifeq:bra%|bra%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| bra
}}
{{#if:{{#ifeq:ket%|ket%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| ket
}} bra–ket notation
{{#if:{{#ifeq:ldelim%|ldelim%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| ldelim
}}
{{#if:{{#ifeq:rdelim%|rdelim%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| rdelim
}} multiline delimiters (2–5 lines inclusive) {{#if:{{#ifeq:ceil%|ceil%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| ceil
}}, {{#if:{{#ifeq:floor%|floor%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| floor
}} calculations :mw:Help:#expr ; formatting indicators ⌈ 3.14⌉ , ⌊ 3.14⌋ (no calculation performed) {{#if:{{#ifeq:pars%|pars%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| pars
}} parentheses that can be resized {{
#if:
|{{ safesubst:#if: |{{{1}}}|(}} ∑ {{ safesubst:#if: |{{{1}}}|)}} |{{#if: 150
|{{ safesubst:#if: |{{{1}}}|(}} |(}}{{
#if: ∑
|∑ | }}{{
#if: 150
|{{ safesubst:#if: |{{{1}}}|)}} |)}}}} {{#if:{{#ifeq:fraction%|fraction%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| fraction
}} slant fractions {{#if:|3+ 5 ⁄{{{3}}} |{{#if:5|3 ⁄5 |{{#if:3|1 ⁄3 |⁄}}}}}} (not for maths/science articles; use standing or upright fractions {{sfrac }} instead) {{#if:{{#ifeq:sfrac%|sfrac%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| sfrac
}} "standing" or upright fractions {{#if:|3+ }}{{#if:|5|{{#if:5|3|1}}}} / 5 (use in maths/science articles instead of{{fraction }} ) {{#if:{{#ifeq:intmath%|intmath%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| intmath
}} integral symbols
{{#if:{{#ifeq:sub%|sub%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| sub
}}
{{#if:{{#ifeq:sup%|sup%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| sup
}}
{{#if:{{#ifeq:su%|su%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| su
}} subscripts and superscripts
{{#if:{{#ifeq:overset%|overset%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| overset
}}
{{#if:{{#ifeq:underset%|underset%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| underset
}} arbitrary characters/diacritics set above/below one another {{#if:{{#ifeq:tmath%|tmath%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| tmath
}} Wrap TeX in <math> tags
Boxes Tags
{{#if:{{#ifeq:arithmetic operations%|arithmetic operations%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| arithmetic operations
}}
{{#if:{{#ifeq:calculus%|calculus%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| calculus
}}
{{#if:{{#ifeq:Infobox mathematical function%|Infobox mathematical function%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| Infobox mathematical function
}}
{{#if:{{#ifeq:functions%|functions%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| functions
}}
{{#if:{{#ifeq:metricate%|metricate%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| metricate
}}
{{#if:{{#ifeq:undue precision%|undue precision%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| undue precision
}}
{{#if:{{#ifeq:units attention%|units attention%||yes}}
| [[Template:{{{2}}}|{{{2}}} ]]
| units attention
}}