Template talk:Convert/nesting

This is the talk-subpage for: Template:Convert/nesting.

Purpose
11-March-2010: This page is used to discuss issues about the depth of nest-levels of the multi-nested subtemplates in Template:Convert. There are related talk-subpages:


 * Also see: Template_talk:Convert - for general discussion.
 * Also see: Template_talk:Convert/density - about density conversions.
 * Also see: Template_talk:Convert/updates - for requesting protected updates.

This talk-subpage is intended to discuss changes to improve the nesting, or improve the explanations, or to help determine the nest-level of a conversion. -Wikid77 (talk) 10:43, 10 March 2010 (UTC)

New rounding routine for less nesting
11-March-2010: There is a new, simplified rounding subtemplate, rndpad, which is intended to bypass the complex, scientific notation rounder, rnd, except for extremely large amounts. For amounts above 85 billion, or rounding above 99 thousand (where n < -5), the full Template:Rnd should be used. However, for most amounts, there is no need to prepare for scientific notation, so the rounding could be done much faster and simpler by rndpad, which can show 10-digit amounts, while also padding for trailing-zeroes in decimal results.

The planned update, to begin using rndpad, would require changing Convert/round to invoke "rndpad" rather than "rnd" (with the same parameters). However, those changes should be tested in sandbox versions of the subtemplates. -Wikid77 10:43, 10 March 2010, revised 20:09, 16 January 2011 (UTC)

Notice of updating Rnd to bypass Rnd/a
11-April-2010: This is just an FYI that Template:Rnd has been updated (on 5 April 2010) to bypass the small subtemplate {Rnd/a} to reduce Convert nesting by 1 more level, against the template-nesting limit. This change affected nearly 307,000 pages, and dropped 307,000 wikilinks to {Rnd/a}, which then became almost unused. See counts in database report:
 * WP:Database reports/Templates with the most transclusions (for Rnd & Rnd/a)

The full talk-page topics are in Template_talk:Rnd:
 * Template_talk:Rnd
 * Template_talk:Rnd
 * Template_talk:Rnd

Those topics describe the issue, with examples. After update, then 305,700 articles were auto-reformatted to de-link {Rnd/a} (within 5 hours on a Sunday night). However, another 1,195 articles were "stuck" as still linking to the unused {Rnd/a}, but hundreds per day later de-linked it, after each article was edited by the pool of thousands of active editors. -Wikid77 18:03, 11 April 2010 (UTC)

Convert uses 17-30 of 40 limit
17-Nov-2010: While it is true that the complexity of Convert's if-logic and nested subtemplates uses about half of the MediaWiki (1.6) expression-nest limit of 40 levels, Convert is NEVER "near" that transclusion depth limit, by itself. When precision is specified as "sigfig=3" or round "0" then Convert uses only 17 nest-levels, leaving 23 available (see examples below). Instead, some of the {Infobox} plus {Documentation} templates have been using more than 11(!) nest levels, of nested subtemplates or if-else logic, before invoking Convert. Although many people might have trouble seeing why Convert of 77 inches to "ft m" (feet-and-metres) uses 29 levels of nested logic, the concept of any {Infobox} template using 8 or 11 levels, of nested logic, totally baffles me. I have run tests which prove that an infobox-table (class=infobox), of couse, causes no nesting, at all. The 8-to-11 levels are caused by complex {Infobox} templates. This is another reason why the current transclusion depth limit of 40 is just too small for the real world: people are creating generalized infoboxes which nest 8-to-11 levels deep, before invoking Convert inside them. Again, the good news is that people can typically specify sigfig=3 or round "0" in many cases, and reduce Convert by the 11 nest-levels used to determine the precision of the input number. In those cases, that allows people to complicate infoboxes by another 11 levels deep.

The following are several live examples which demonstrate that Convert can be used inside templates nested 12 levels deep, or 22 deep for sigfig=3 or round "0" (and such). Specifying the precision will free another 11 levels, so that Convert, with precision, uses less than half of the total limit.
 * Nest 23 templates - {convert|12|km|mi|0}:


 * Nest 23 templates - {convert|12|km|mi|0}:
 * Nest 13 templates - typical {convert|45|km|mi}:


 * Nest 13 templates - typical {convert|45|km|mi}:
 * Nest 11 templates - Dual-output {convert|67|km|ft m}:


 * Nest 11 templates - Dual-output {convert|67|km|ft m}:

Having 2 dual output amounts, such as "ft m" increases the Convert nesting by 2 more levels. In all cases I have seen, Convert uses less than 30 of the 40 total nesting levels allowed in 2009-2010. Setting the precision, sigfig=3 or round "0" will free another 11 levels. -Wikid77 (talk) 05:14, 17 November 2010, revised 15:30, 6 November 2012 (UTC)

Reducing the nested templates
17-Nov-2010: Some reduction of nested templates, used inside the convert calculations, has already been done:
 * Template:Rnd was changed to bypass Template:Rnd/a.
 * [[Template:xx] was changed to bypass Template:xx/a.

Similarly, Template:Precision is being modified to bypass Template:Precision/a, which had merely allowed 2 instances of parser-function {#titleparts:xxxx|1|2} to be specified as parameter {2} passed into {Precision/a}. Because Template:Precision, and its subtemplates, has been using 8 levels of nesting, it has been discussed for years as an area to reduce the nesting.

See more details at: Template_talk:Precision. -Wikid77 (talk) 15:09, 17 November 2010 (UTC)

Expansion depth if rounding scientific notation
Some conversions, reaching into billions, are nearing the MediaWiki expansion depth limit, so in ranges, an amount of 2 billion exceeds the limit


 * {convert|2,000,000|km|m} &rarr; 2,000,000 km
 * {convert|20,000,000|km|m} &rarr; 20,000,000 km
 * {convert|3,787,878.8|mi|ft} &rarr; 3,787,878.8 mi
 * {convert|1000|-|2,000,000|km|m} &rarr; 1000 - 2,000,000 km
 * {convert|1000|-|3,787,878.8|mi|ft} &rarr; 1000 - 3,787,878.8 mi

Much of the nested expansion is occurring inside Template:rnd, which requires 17 expansion levels and cannot function when nested 24 levels deep, but works when 23 deep (of the 40-level limit):
 * Nest 24 templates & {rnd|2000000400|-3}:

However, the Template:Rndpad requires only 8 expansion levels to round billions, and it can round 2 billion (2,000,000,400) when nested even 32 levels deep, rather than only 22 levels:
 * Nest 24 templates & {rnd|2000000400|-3}:
 * Nest 23 templates & {rnd|2000000400|-3}:
 * Nest 32 templates & {rndpad|2000000400|-3}:
 * Nest 33 templates & {rndpad|2355.07|1}:
 * Nest 34 templates & {rnd|2355.07|1}: Expression error: Unexpected < operator

Because {rndpad} does not use scientific notation until over 85 billion, it can handle all ranges of millions, plus billions up through 84 billion, using only 7-8 expansion levels. -Wikid77 20:09, 16 January 2011 (UTC)