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

From Basin Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
−
 
+
<noinclude><noinclude>
−
<noinclude>
 
 
== Usage ==
 
== Usage ==
  
 
<code><nowiki>{{Range/Unsigned|min|max}}</nowiki></code>
 
<code><nowiki>{{Range/Unsigned|min|max}}</nowiki></code>
−
 
−
The template displays an unsigned range using a hyphen as the separator. Negative boundaries are enclosed in parentheses to avoid ambiguity.
 
  
 
== Parameters ==
 
== Parameters ==
Line 25: Line 22:
 
== Behavior ==
 
== Behavior ==
  
−
* Both parameters are displayed as a range separated by a hyphen.
+
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>.
−
* Negative values are enclosed in parentheses.
+
 
−
* Non-negative values are displayed without additional parentheses.
+
* '''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.
−
* The template does not add 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 ==
 
== Examples ==
Line 37: Line 35:
 
! Description
 
! Description
 
|-
 
|-
−
| <code><nowiki>{{Range/Unsigned|1|2}}</nowiki></code>
+
| <code><nowiki>{{Range/Unsigned|10|30}}</nowiki></code>
−
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|1|2}}
+
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|10|30}}
−
| Positive range
+
| Both boundaries are positive.
 
|-
 
|-
−
| <code><nowiki>{{Range/Unsigned|0|2}}</nowiki></code>
+
| <code><nowiki>{{Range/Unsigned|0|30}}</nowiki></code>
−
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|0|2}}
+
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|0|30}}
−
| Range starting at zero
+
| Minimum is zero and maximum is positive.
 
|-
 
|-
−
| <code><nowiki>{{Range/Unsigned|-1|2}}</nowiki></code>
+
| <code><nowiki>{{Range/Unsigned|-30|10}}</nowiki></code>
−
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-1|2}}
+
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-30|10}}
−
| Negative minimum and positive maximum
+
| Minimum is negative and maximum is positive.
 
|-
 
|-
−
| <code><nowiki>{{Range/Unsigned|-1|0}}</nowiki></code>
+
| <code><nowiki>{{Range/Unsigned|-30|0}}</nowiki></code>
−
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-1|0}}
+
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-30|0}}
−
| Negative minimum and zero maximum
+
| Minimum is negative and maximum is zero.
 
|-
 
|-
−
| <code><nowiki>{{Range/Unsigned|-2|-1}}</nowiki></code>
+
| <code><nowiki>{{Range/Unsigned|-30|-10}}</nowiki></code>
−
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-2|-1}}
+
| {{User:Trang Oul/Sandbox/Template:Range/Unsigned|-30|-10}}
−
| Negative range
+
| Both boundaries are negative.
 
|}
 
|}
−
 
 
</noinclude><includeonly>({{#ifexpr: {{{1}}} < 0 | ({{{1}}}) | {{{1}}} }}-{{#ifexpr: {{{2}}} < 0 | ({{{2}}}) | {{{2}}} }})</includeonly>
 
</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.