Difference between revisions of "User:Trang Oul/Sandbox/Template:Range/Signed"
< User:Trang Oul | Sandbox | Template:Range
Jump to navigation
Jump to search
(Created page with "<noinclude> Usage: <code><nowiki>{{Range/Signed|min|max}}</nowiki></code> Examples: * ++: {{User:Trang Oul/Sandbox/Template:Range/Signed|1|2}} * 0+: {{User:Trang Oul/Sandbox/T...") |
|||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<noinclude> | <noinclude> | ||
| − | Usage | + | == Usage == |
| − | + | ||
| − | * + | + | <code><nowiki>{{Range/Signed|min|max}}</nowiki></code> |
| − | + | ||
| − | + | == Parameters == | |
| − | + | ||
| − | + | {| class="wikitable" | |
| − | </noinclude><includeonly> | + | ! Parameter |
| + | ! Description | ||
| + | ! Default | ||
| + | |- | ||
| + | | <code>1</code> (<code>min</code>) | ||
| + | | The lower bound of the range. | ||
| + | | | ||
| + | |- | ||
| + | | <code>2</code> (<code>max</code>) | ||
| + | | The upper bound of the range. | ||
| + | | | ||
| + | |} | ||
| + | |||
| + | == Behavior == | ||
| + | |||
| + | This template formats a range using the two bounds <code>min</code> and <code>max</code>. It expects <code>min</code> to be less than or equal to <code>max</code>. | ||
| + | |||
| + | * '''Non-negative range (<code>min</code> ≥ 0):''' Encloses the range in parentheses and prefixes it with a leading <code>+</code> sign. Both boundaries retain their original parameter order. | ||
| + | * '''Non-positive range (<code>max</code> ≤ 0):''' Displays the absolute values of both boundaries in reverse parameter order (<code>max</code> before <code>min</code>), enclosing the range in parentheses and prefixing it with a leading <code>-</code> sign. | ||
| + | * '''Mixed-sign range (otherwise):''' Encloses the range and each boundary in parentheses, preserving the original parameter order and marking the positive maximum with a leading <code>+</code> sign. | ||
| + | |||
| + | == Examples == | ||
| + | |||
| + | {| class="wikitable" | ||
| + | ! Input | ||
| + | ! Result | ||
| + | ! Description | ||
| + | |- | ||
| + | | <code><nowiki>{{Range/Signed|10|30}}</nowiki></code> | ||
| + | | {{User:Trang Oul/Sandbox/Template:Range/Signed|10|30}} | ||
| + | | Both boundaries are positive. | ||
| + | |- | ||
| + | | <code><nowiki>{{Range/Signed|0|30}}</nowiki></code> | ||
| + | | {{User:Trang Oul/Sandbox/Template:Range/Signed|0|30}} | ||
| + | | Minimum is zero and maximum is positive. | ||
| + | |- | ||
| + | | <code><nowiki>{{Range/Signed|-30|10}}</nowiki></code> | ||
| + | | {{User:Trang Oul/Sandbox/Template:Range/Signed|-30|10}} | ||
| + | | Minimum is negative and maximum is positive. | ||
| + | |- | ||
| + | | <code><nowiki>{{Range/Signed|-30|0}}</nowiki></code> | ||
| + | | {{User:Trang Oul/Sandbox/Template:Range/Signed|-30|0}} | ||
| + | | Minimum is negative and maximum is zero. | ||
| + | |- | ||
| + | | <code><nowiki>{{Range/Signed|-30|-10}}</nowiki></code> | ||
| + | | {{User:Trang Oul/Sandbox/Template:Range/Signed|-30|-10}} | ||
| + | | Both boundaries are negative. | ||
| + | |} | ||
| + | </noinclude><includeonly>{{#ifexpr: {{{1}}} >= 0 | ||
| + | | +({{{1}}}-{{{2}}}) | ||
| + | | {{#ifexpr: {{{2}}} <= 0 | ||
| + | | -({{#expr: abs({{{2}}}) }}-{{#expr: abs({{{1}}}) }}) | ||
| + | | (({{{1}}})-(+{{{2}}})) | ||
| + | }} | ||
| + | }}</includeonly> | ||
Latest revision as of 20:30, 4 November 2026
Usage
{{Range/Signed|min|max}}
Parameters
| Parameter | Description | Default |
|---|---|---|
1 (min)
|
The lower bound of the range. | |
2 (max)
|
The upper bound of the range. |
Behavior
This template formats a range using the two bounds min and max. It expects min to be less than or equal to max.
- Non-negative range (
min≥ 0): Encloses the range in parentheses and prefixes it with a leading+sign. Both boundaries retain their original parameter order. - Non-positive range (
max≤ 0): Displays the absolute values of both boundaries in reverse parameter order (maxbeforemin), enclosing the range in parentheses and prefixing it with a leading-sign. - Mixed-sign range (otherwise): Encloses the range and each boundary in parentheses, preserving the original parameter order and marking the positive maximum with a leading
+sign.
Examples
| Input | Result | Description |
|---|---|---|
{{Range/Signed|10|30}}
|
+(10-30) | Both boundaries are positive. |
{{Range/Signed|0|30}}
|
+(0-30) | Minimum is zero and maximum is positive. |
{{Range/Signed|-30|10}}
|
((-30)-(+10)) | Minimum is negative and maximum is positive. |
{{Range/Signed|-30|0}}
|
-(0-30) | Minimum is negative and maximum is zero. |
{{Range/Signed|-30|-10}}
|
-(10-30) | Both boundaries are negative. |