Difference between revisions of "Template:Max/6"
imported>Wikid77 (typo 2nd "max/3" was "max/2") |
imported>Wikid77 (try "+ 0" in each {# expr: ...}) |
||
Line 6: | Line 6: | ||
--></noinclude>{{max/2 | --></noinclude>{{max/2 | ||
|{{max/3 | |{{max/3 | ||
− | |{{#iferror:{{#expr:{{{1|0}}}0 }} |-9e99|{{{1|0}}} }} | + | |{{#iferror:{{#expr:{{{1|0}}}+0 }} |-9e99|{{{1|0}}} }} |
− | |{{#iferror:{{#expr:{{{2|0}}}0 }} |-9e99|{{{2|-9e99}}} }} | + | |{{#iferror:{{#expr:{{{2|0}}}+0 }} |-9e99|{{{2|-9e99}}} }} |
− | |{{#iferror:{{#expr:{{{3|0}}}0 }} |-9e99|{{{3|-9e99}}} }} | + | |{{#iferror:{{#expr:{{{3|0}}}+0 }} |-9e99|{{{3|-9e99}}} }} |
}}|{{max/3 | }}|{{max/3 | ||
− | |{{#iferror:{{#expr:{{{4|0}}}0 }} |-9e99|{{{4|-9e99}}} }} | + | |{{#iferror:{{#expr:{{{4|0}}}+0 }} |-9e99|{{{4|-9e99}}} }} |
− | |{{#iferror:{{#expr:{{{5|0}}}0 }} |-9e99|{{{5|-9e99}}} }} | + | |{{#iferror:{{#expr:{{{5|0}}}+0 }} |-9e99|{{{5|-9e99}}} }} |
− | |{{#iferror:{{#expr:{{{6|0}}}0 }} |-9e99|{{{6|-9e99}}} }} | + | |{{#iferror:{{#expr:{{{6|0}}}+0 }} |-9e99|{{{6|-9e99}}} }} |
}}<!--end max/3 #2--> | }}<!--end max/3 #2--> | ||
}}<!--end max/2 #1 -- get max of two groups of 3 and 3 numbers | }}<!--end max/2 #1 -- get max of two groups of 3 and 3 numbers |
Revision as of 15:20, 30 August 2012
- redirect Template:Max

The Template:Max/6 returns the maximum number, out of 6 parameters, where some parameters can be ignored as text entries rather than numbers (such as a parameter with "none" or "n/a" or "-").
- Usage: {{max/6 | 1 | 5 | 8 | 4 | 7 | 3 }} → 8
- {{max/6 |24|65|(pass)|87|4|none}} → 87
- {{max/6 | -7 |-4 |-2 |-1 |-6 | -9 }} → -1
- {{max/6 | x | 34 | - | z | 30 | 31 }} → 34
- Usage: {{max/6 | 1 | 5 | 8 | 4 | 7 | 3 }} → 8
To set a floor amount, as a minimum result, also pass a specified amount, such as "50" where {{max/6 |1|2|3|4|5|50}} will return at least 50 as the maximum. Otherwise, negative numbers are allowed, to find the highest among negative numbers, when all negative.
- Peformance considerations
This template, in turn, uses Template:Max/3 twice to find the maximum among two groups of 3 and 3 parameters, but it also skips any invalid or text data in the entries, such as "(pass)" or "n/a" or "--" or "none" etc. Hence, only the numeric parameters are compared, not the text words.
The template-expansion depth is kept to a minimum, as 8 nesting levels, by avoiding deeply nested if-else-else-else structures.
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Subpages of this template. |