Template:Rndpad/doc

From Self-sufficiency
Jump to: navigation, search

The rounding routine Template:Rndpad can round up to 85 billion as 11-digit format, with decimals padded by trailing zeroes, when the round setting > -5, but can display scientific notation above 85 billion (8.5E+10) for any number of digits.

Usage

{{rndpad|7.58|1}} → 7.6
{{rndpad|7001.58|0}} → 7002
{{rndpad|9730070681.45003|-3}} → 9,730,071,000
{{rndpad|9730070681.45003|4}} → 9,730,070,681.4500
{{rndpad|9000000000.40|0}} → 9,000,000,000

See also

  • {{rnd|amount|n}} - round amount, allow scientific notation at 8.0E+5
  • {{rnd/-|amount|n}} - round a decimal padded with trailing zeroes

Detailed examples

Examples of rounding to each of 11 digits:
  • {{rndpad|90711.45003| -4 }}   → 90,000
  • {{rndpad|79730000006.40|0}}   → 79,730,000,006
  • {{rndpad|80561.45003| -5 }}   → 100,000
  • {{rndpad|80561.45003| -4 }}   → 80,000
  • {{rndpad|80561.45003| -3 }}   → 81,000
  • {{rndpad|80561.45003| -2 }}   → 80,600
  • {{rndpad|80561.45003| -1 }}   → 80,560
  • {{rndpad|80561.45003| 0 }}   → 80,561
  • {{rndpad|80561.45003| 1 }}   → 80,561.5
  • {{rndpad|80561.45003| 2 }}   → 80,561.45
  • {{rndpad|80561.45003| 3 }}   → 80,561.450
  • {{rndpad|80561.45003| 4 }}   → 80,561.4500
  • {{rndpad|80561.45003| 5 }}   → 80,561.45003
  • {{rndpad|80561.45003| 6 }}   → 80,561.450030

Technical issues

The Template:Rndpad typically uses only one subtemplate, {{rnd/-}}, when rounding numbers below 85 billion, and the internal markup coding is nested only 3 levels deep, of nested-if expressions. However, for numbers over 85 billion, up to 8 subtemplates are invoked, and the nesting level can be more than 12 levels deep. Inside a single page, invoking {{rndpad}} uses only 1 level of nesting, so an if-expression could be nested 39 levels deep, and then invoke rndpad as the 40th-level of nesting. However, inside an infobox, the depth-limit message might be announced as "Expansion depth limit exceeded" at 41 levels.