Difference between revisions of "User:Trang Oul/Sandbox/Template:Range/Unsigned"

From Basin Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
−
<noinclude>
+
<noinclude><noinclude>
−
Usage: <code><nowiki>{{Range/Unsigned|min|max}}</nowiki></code>
+
== Usage ==
  
−
Examples:
+
<code><nowiki>{{Range/Unsigned|min|max}}</nowiki></code>
−
* ++: {{User:Trang Oul/Sandbox/Template:Range/Unsigned|1|2}}
+
 
−
* 0+: {{User:Trang Oul/Sandbox/Template:Range/Unsigned|0|2}}
+
== Parameters ==
−
* -+: {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-1|2}}
+
 
−
* -0: {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-1|0}}
+
{| class="wikitable"
−
* --: {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-2|-1}}
+
! Parameter
−
</noinclude><includeonly>({{#ifexpr: (0 + {{{1}}}) < 0 | ({{{1}}}) | {{{1}}} }}-{{#ifexpr: (0 + {{{2}}}) < 0 | ({{{2}}}) | {{{2}}} }})</includeonly>
+
! 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, preserving the original parameter order without additional parentheses around the boundaries or explicit positive signs.
 +
* '''Non-positive range (<code>max</code> ≤ 0):''' Encloses the range in parentheses, preserving the original parameter order and additionally enclosing each negative boundary in parentheses.
 +
* '''Mixed-sign range (otherwise):''' Encloses the range in parentheses, preserving the original parameter order and additionally enclosing the negative minimum in parentheses.
 +
 
 +
== Examples ==
 +
 
 +
{| class="wikitable"
 +
! Input
 +
! Result
 +
! Description
 +
|-
 +
| <code><nowiki>{{Range/Unsigned|10|30}}</nowiki></code>
 +
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|10|30}}
 +
| Both boundaries are positive.
 +
|-
 +
| <code><nowiki>{{Range/Unsigned|0|30}}</nowiki></code>
 +
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|0|30}}
 +
| Minimum is zero and maximum is positive.
 +
|-
 +
| <code><nowiki>{{Range/Unsigned|-30|10}}</nowiki></code>
 +
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-30|10}}
 +
| Minimum is negative and maximum is positive.
 +
|-
 +
| <code><nowiki>{{Range/Unsigned|-30|0}}</nowiki></code>
 +
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-30|0}}
 +
| Minimum is negative and maximum is zero.
 +
|-
 +
| <code><nowiki>{{Range/Unsigned|-30|-10}}</nowiki></code>
 +
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-30|-10}}
 +
| Both boundaries are negative.
 +
|}
 +
</noinclude><includeonly>({{#ifexpr: {{{1}}} < 0 | ({{{1}}}) | {{{1}}} }}-{{#ifexpr: {{{2}}} < 0 | ({{{2}}}) | {{{2}}} }})</includeonly>

Latest revision as of 20:30, 4 November 2026

Usage

{{Range/Unsigned|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, preserving the original parameter order without additional parentheses around the boundaries or explicit positive signs.
  • Non-positive range (max ≤ 0): Encloses the range in parentheses, preserving the original parameter order and additionally enclosing each negative boundary in parentheses.
  • Mixed-sign range (otherwise): Encloses the range in parentheses, preserving the original parameter order and additionally enclosing the negative minimum in parentheses.

Examples

Input Result Description
{{Range/Unsigned|10|30}} (10-30) Both boundaries are positive.
{{Range/Unsigned|0|30}} (0-30) Minimum is zero and maximum is positive.
{{Range/Unsigned|-30|10}} ((-30)-10) Minimum is negative and maximum is positive.
{{Range/Unsigned|-30|0}} ((-30)-0) Minimum is negative and maximum is zero.
{{Range/Unsigned|-30|-10}} ((-30)-(-10)) Both boundaries are negative.