Template documentation

This template is the core template of Template:Formatnum. That template handles the empty string and invalid numbers, and the possible minus sign, so that this template needs to handle valid non-negative numbers only. Also Formatnum applies rounding according to parameter prec, if defined, and increases the absolute value so that this template can truncate after a total of 16 digits, and supplies this template with the log to the base 10, rounded down, of this final number.

Parameters

edit
Parameter name Description Default value
1 non-negative number empty
2 language code value of {{int:Lang}}
sep set to any non-empty value to produce a result without thousands separators empty
prec number of digits after the decimal point to show if empty or undefined: 0
oom log to the base 10, rounded down, of the number. empty

Examples

  • {{formatnum|1234567890.456789789}} → 1,234,567,890.4568
  • 1,234,567,890.45679
  • {{#expr:(abs(.456789789)+5*10^(-16+9))}} → 0.456790289
  • {{formatnum|9999999999.99999}} → 10,000,000,000
  • {{formatnum/1|(9999999999.99999+5*10^(-16+9))|oom=9}} → 9,999,999,999.99999
  • {{#expr:(abs(.99999)+5*10^(-16+9))}} → 0.9999905
  • {{oom|10000000000}} → 10
  • {{formatnum|9999999999.999999}} → 10,000,000,000
  • {{formatnum/1|(9999999999.999999+5*10^(-16+9))|oom=9}} → 9,999,999,999.999998
  • {{#expr:(abs(.999999)+5*10^(-16+9))}} → 0.9999995
  • {{oom|(abs(9999999999.999999)+5*10^(-16+9))}} → 9

Compare:

    • {{oom|{{#expr:(abs(9999999999.999999)+5*10^(-16+9))}}}} → 10
    • {{formatnum/1|(9999999999.999999+5*10^(-16+9))|oom=10}} → 9,999,999,999.99999
  • {{formatnum|9999999999.9999999}} → 10,000,000,000
  • {{formatnum/1|(9999999999.9999999+5*10^(-16+9))|oom=10}} → 10,000,000,000
  • {{#expr:(abs(.9999999)+5*10^(-16+9))}} → 1.0000004
  • {{oom|(abs(9999999999.9999999)+5*10^(-16+9))}} → 10


  • {{formatnum|123456789012.12}} → 123,456,789,012.12
  • {{formatnum|12345678901.12}} → 12,345,678,901.12
  • {{formatnum|1234567890.12}} → 1,234,567,890.12
  • {{formatnum|234567890.12}} → 234,567,890.12
  • {{formatnum|34567890.12}} → 34,567,890.12
  • {{formatnum|4567890.12}} → 4,567,890.12
  • {{formatnum|567890.12}} → 567,890.12
  • {{formatnum|67890.12}} → 67,890.12
  • {{formatnum|7890.12}} → 7,890.12
  • {{formatnum|890.12}} → 890.12
  • {{formatnum|90.12}} → 90.12
  • {{formatnum|4.12}} → 4.12
  • {{formatnum|4.1}} → 4.1
  • {{formatnum|4}} → 4
  • {{formatnum|1234567890.12345}} → 1,234,567,890.1235
  • {{formatnum|1234567890.123456}} → 1,234,567,890.1235
  • {{formatnum|1234567890|prec=3}} → 1,234,567,890.000
  • {{formatnum|1234567890.1|prec=3}} → 1,234,567,890.100
  • {{formatnum|1234567890.12|prec=3}} → 1,234,567,890.120
  • {{formatnum|1234567890.123|prec=3}} → 1,234,567,890.123
  • {{formatnum|1234567890.1234|prec=3}} → 1,234,567,890.123
  • {{formatnum|1234567890.12345|prec=3}} → 1,234,567,890.123
  • {{formatnum|1234567890.123456|prec=3}} → 1,234,567,890.123
  • {{formatnum|0.000123456|prec=3}} → 0.000
  • {{formatnum|9999999999.9999}} → 9,999,999,999.9999
  • {{formatnum|9999999999.99999}} → 10,000,000,000
  • {{formatnum|9999999999.999999}} → 10,000,000,000
  • {{formatnum|9999999999.9999999}} → 10,000,000,000
  • {{formatnum|-6.7e-8}} → −6.7E−8
  • {{formatnum|0}} → 0
  • {{formatnum|0|bn}} → ০
  • {{formatnum|6.7e-18}} → 6.7E−18
  • {{formatnum|6.7e-8}} → 6.7E−8
  • {{formatnum|6.7e8}} → 670,000,000
  • {{formatnum|1.234567890123456e17}} → 1.2345678901235E17
  • {{formatnum|6.7e17}} → 6.7E17
  • {{formatnum|1.234567890123456e18}} → 1.2345678901235E18
  • {{formatnum|6.7e18}} → 6.7E18
  • {{formatnum|e8}} → e8 (not a valid number, returns the input)
  • {{formatnum}}

Required

Localization

This template does not have to be localized itself.