Description
This template formats a number with the specified number of significant digits to the right of the decimal point. In other words, the template will add trailing zeroes after the decimal point, when necessary, until the number contains the specified number of digits after the decimal point. This allows proper alignment of numbers within a table.
Use negative numbers in the "decimals" field to round to the left of the decimal point.
The template will accept and evaluate an expression in place of a raw number.
Syntax
{{Decimals|<number or expression>|<decimals (limited to 12) (0 if omitted)>}}
Sample output
  • {{Decimals|1234|-2}} → 1200 (-2 forces rounding to the nearest 100.)
  • {{Decimals|1234|-3}} → 1200 (-3 forces rounding to the nearest 1,000.)
  • {{Decimals|1234|0}} → 1234
  • {{Decimals|1234}} → 1234 (decimals = 0, when final parameter is omitted.)
  • {{Decimals|1234|1}} → 1234.0
  • {{Decimals|1234|2}} → 1234.00
  • {{Decimals|9/8|5}} → 1.12500
  • {{Decimals|1/3|15}} → 0.333333333333 (Only the first 12 digits are returned.)
  • {{Decimals|1/33|7}} → 0.0303030
  • {{Decimals|0.006|1}} → 0.0

See also

  • Template:Formdec - Applies parser function {{#formatnum:}} to the output of above template.
This page uses Creative Commons Licensed content from Wikipedia (view authors).
Community content is available under CC-BY-SA unless otherwise noted.