Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{documentation subpage}}
{{documentation subpage}}
{{dependencies|Module:Convert|Module:Convert/data|Module:Convert/text}}
'''Template {{tl|convert}}''' calculates a measurement value (''number × unit'') into the same measurement by a different unit, and then presents the results, formatted.  See also the [[Module:Convert/documentation/conversion data|unit symbols recognized by this template]].
{{Uses TemplateStyles|Template:Fraction/styles.css|Template:Sfrac/styles.css}}
'''{{tl|convert}}''' calculates a measurement value (''number × unit'') into the same measurement by a different unit, and then presents the results, formatted.  See also the [[w:Module:Convert/documentation/conversion data|unit symbols recognized by this template]].


For example:
For example:
Line 19: Line 17:
:<code><nowiki>{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}</nowiki></code> → {{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
:<code><nowiki>{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}</nowiki></code> → {{convert|2|and|5|km|mi|sigfig=3|abbr=off}}


{{hatnote|See [[w:Help:Convert]] for more detailed, technical information}}
{{hatnote|See [[Help:Convert]] for more detailed, technical information}}


==Units to convert==
==Units to convert==
{{hatnote|See also: the summary at [[w:Template:Convert/list of units|Complete list of units for <code><nowiki>{{Convert}}</nowiki></code>]] and the complete list at [[ w:Module:Convert/documentation/conversion data]]}}
{{hatnote|See also: the summary at [[Template:Convert/list of units|Complete list of units for {{tlf|Convert}}]] and the complete list at [[ Module:Convert/documentation/conversion data]]}}
Enter units to convert ''from''&nbsp;''into'':
Enter units to convert ''from''&nbsp;''into'':
* <code><nowiki>{{convert|1|lb|kg}}</nowiki></code> → {{convert|1|lb|kg}}
* <code><nowiki>{{convert|1|lb|kg}}</nowiki></code> → {{convert|1|lb|kg}}
:[[w:International System of Units|SI]] units generally accept prefixes, like "m" for milli (10<sup>−3</sup>), and "M" for mega (10<sup>6</sup>)
:[[International System of Units|SI]] units generally accept prefixes, like "m" for milli (10<sup>−3</sup>), and "M" for mega (10<sup>6</sup>)
:For "per" units, use "/" (slash): kg/ha (see [[#'per'_units:_kg/ha,_miles_per_gallon|§&nbsp;'per' units: kg/ha]] and [[#Currency per unit: $/mi → $/km|§&nbsp;Currency per unit: $/km]])
:For "per" units, use "/" (slash): kg/ha (see [[#'per'_units:_kg/ha,_miles_per_gallon|§&nbsp;'per' units: kg/ha]] and [[#Currency per unit: $/mi → $/km|§&nbsp;Currency per unit: $/km]])
:For three-unit units, etc., see {{cl|Convert-like templates}}


==Unit name or symbol (abbreviation): ''1 pound'' or ''1 lb''?==
==Unit name or symbol (abbreviation): ''1 pound'' or ''1 lb''?==
Line 51: Line 50:
* <code><nowiki>{{convert|10|mi|km}} to go</nowiki></code> → {{convert|10|mi|km}} to go.
* <code><nowiki>{{convert|10|mi|km}} to go</nowiki></code> → {{convert|10|mi|km}} to go.


{{para|adj|on}} does not produce hyphens with unit symbols.
{{para|adj|on}} does not produce hyphens with unit symbols, as per [[MOS:UNITSYMBOLS|Manual of Style]]:
* <code><nowiki>A {{convert|9|in|cm|adj=on|abbr=on}} nail</nowiki></code> → A {{convert|9|in|cm|adj=on|abbr=on}} nail.
* <code><nowiki>A {{convert|9|in|cm|adj=on|abbr=on}} nail</nowiki></code> → A {{convert|9|in|cm|adj=on|abbr=on}} nail.


==Rounding: ''100 ft'' is ''30&nbsp;m'' or ''30.5&nbsp;m'' or ''30.48&nbsp;m''?<span class="anchor" id="Rounding"></span>==
==Rounding: ''100 ft'' is ''30&nbsp;m'' or ''30.5&nbsp;m'' or ''30.48&nbsp;m''?<span class="anchor" id="Rounding"></span>==
{{hatnote|See [[w:Help:Convert#Rounding]] for a more mathematical description of the rounding options}}
{{hatnote|See {{section link|Help:Convert#Rounding}} for a more mathematical description of the rounding options}}
By definition, 100&nbsp;ft equals {{convert|100|ft|m|sigfig=4|disp=out}}. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
By definition, 100&nbsp;ft equals {{convert|100|ft|m|sigfig=4|disp=out}}. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.


Line 97: Line 96:


===Round to a given precision: ''use a precision number''===
===Round to a given precision: ''use a precision number''===
Specify the desired precision with an integer as the ''fourth unnamed parameter'' (or third unnamed parameter if the "convert to" parameter is omitted; or fifth unnamed parameter if a range is specified; or fourth unnamed parameter again if a range is specified and the "convert to" parameter is omitted; needs to be replaced with a "precision" named parameter). The conversion is rounded off to the nearest multiple of 10 to the power of this integer. For instance, if the result is 8621 and the rounding parameter is "−2", 8600 will be displayed. If the result is "123.456" and the parameter is "0", 123 will be displayed. Essentially a positive or zero rounding parameter specifies the number of decimal places; a negative value specifies the number of trailing zeroes.
Specify the desired precision with an integer as the ''fourth unnamed parameter'' (or third unnamed parameter if the "convert to" parameter is omitted; or fifth unnamed parameter if a range is specified; or fourth unnamed parameter again if a range is specified and the "convert to" parameter is omitted; needs to be replaced with a "precision" named parameter). The conversion is rounded off to the nearest multiple of {{frac|10}} to the power of this integer. For instance, if the result is 8621 and the rounding parameter is "−2", 8600 will be displayed. If the result is "123.456" and the parameter is "0", 123 will be displayed. Essentially a positive or zero rounding parameter specifies the number of decimal places; a negative value specifies the number of trailing zeroes.


===Round to a given number of significant figures: ''{{para|sigfig|}}''<span class="anchor" id="Round to a given number of significant figures"></span>===
===Round to a given number of significant figures: ''{{para|sigfig|}}''<span class="anchor" id="Round to a given number of significant figures"></span>===
Line 108: Line 107:
* <code><nowiki>{{convert|1200|ft|m}}</nowiki></code> → {{convert|1200|ft|m}}
* <code><nowiki>{{convert|1200|ft|m}}</nowiki></code> → {{convert|1200|ft|m}}
Setting {{para|sigfig}} to a value less than 1 is meaningless:
Setting {{para|sigfig}} to a value less than 1 is meaningless:
* <code><nowiki>{{convert|1200|ft|m|sigfig=0}}</nowiki></code> → {{convert|1200|ft|m|sigfig=0}}
* <code><nowiki>{{convert|1200|ft|m|sigfig=0}}</nowiki></code> → {{convert|1200|ft|m|sigfig=0}} {{nay}}


===Round to a multiple of 5: ''15'', ''20'', ''25'', ...===
===Round to a multiple of 5: ''15'', ''20'', ''25'', ...===
Line 126: Line 125:


===<span id="Round to a multiple of a given fraction"></span>Round to a multiple of a given fraction: ''{{frac|2|3|16}} inch''===
===<span id="Round to a multiple of a given fraction"></span>Round to a multiple of a given fraction: ''{{frac|2|3|16}} inch''===
Specify the desired ''denominator'' using {{para|frac|&lt;some positive integer&gt;}}. ([[w:Fraction (mathematics)|Denominator]] is the below-the-slash number, for example the 3 in {{frac|1|3}}).
Specify the desired ''denominator'' using {{para|frac|&lt;some positive integer&gt;}}. ([[Fraction (mathematics)|Denominator]] is the below-the-slash number, for example the 3 in {{frac|1|3}}).
* <code><nowiki>{{convert|5.56|cm|in|frac=16}}</nowiki></code> → {{convert|5.56|cm|in|frac=16}}
* <code><nowiki>{{convert|5.56|cm|in|frac=16}}</nowiki></code> → {{convert|5.56|cm|in|frac=16}}
* <code><nowiki>{{convert|8|cm|in|frac=4}}</nowiki></code> → {{convert|8|cm|in|frac=4}}
* <code><nowiki>{{convert|8|cm|in|frac=4}}</nowiki></code> → {{convert|8|cm|in|frac=4}}
Line 133: Line 132:
Default behavior uses decimal notation:
Default behavior uses decimal notation:
* <code><nowiki>{{convert|5.56|cm|in}}</nowiki></code> → {{convert|5.56|cm|in}}
* <code><nowiki>{{convert|5.56|cm|in}}</nowiki></code> → {{convert|5.56|cm|in}}
===Rounding temperatures: ''°C'', ''°F'' and ''K''<span class="anchor" id="Rounding temperatures"></span>===
In temperatures, the conversion will be rounded either to the precision comparable to that of the input value or to that which would give three significant figures when expressed in kelvins, whichever is more precise.
#{{#invoke:DemoTemplate|convert|10,000|C|F K}}
#{{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
#{{#invoke:DemoTemplate|convert|-272|C|F K}}
#{{#invoke:DemoTemplate|convert|-272|C}}
#{{#invoke:DemoTemplate|convert|100|C|F K}}
#{{#invoke:DemoTemplate|convert|0|C|F K}}
The precision of the input number in example (1) is one digit, but the precision of its kelvins expression is three, so the precision of the Fahrenheit conversion is ''made'' three (made 180...) . (1) and (2) seem to belie the fact that a {{convert|0.1|C-change|F-change|disp=x| is a |abbr=off}}, and make the 32 degrees difference shown in (1) begin to seem off somehow.
Result (1) seems off until you set the significant figures yourself with {{para|sigfig}}:
:{{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision ''positionally'', relative to the decimal point (zero being ''at'' the decimal point):
:{{#invoke:DemoTemplate|convert|10000|C|0}}
The precision of the input number in example (2) is six, so the precision of the Fahrenheit output is six now, whereas before kelvins had determined it to be three. Examples (3) and (4) show how this can be hidden and generate questions, but it occurs there because the kelvins conversion generated the fractional parts. (Before it was the input number that generated the fractional part.)  In example (3) the three input digits converted into five significant output digits because of the two digits after the decimal point, generated by the kelvins conversion. This happened again in (5), but in (6) decimal fractions were neither given as input nor induced by the kelvins conversion.


===Rounding input===
===Rounding input===
Line 176: Line 157:


See also:
See also:
* For multiple-unit options like ''1 ft 5 in'', see [[#In input]] and [[#In output]].
* For multiple-unit options like ''1 ft 5 in'', see {{section link||In input}} and {{section link||In output}}.


==Ranges of values==
==Ranges of values==
{{hatnote|For a conversion of a difference, see [[#Units of difference]]}}
{{For|a conversion of a difference|#Units of difference}}
A ''range'' converts ''two'' values and separates them by your choice of words and punctuation.
A ''range'' converts ''two'' values and separates them by your choice of words and punctuation.


===A range: ''6 to 17 kg (13 to 37 lb)''===
===A range: ''6 to 17 kg (13 to 37 lb)''===
Range indicators are entered as the second parameter (between the values). Range separators can be:<br/>
Range indicators are entered as the second parameter (between the values). Range separators can be:<br/>
{| class="wikitable sortable collapsible" style="width:100%;"
{{Convert/doc/range separator list}}
|+ style="background:#eee;" | Range separators in <nowiki>{{convert}}</nowiki>
|-
! Separator
! Convert
! Result
! Notes
|-
| <code>-</code>
| <code><nowiki>{{convert|3|-|6|ft}}</nowiki></code>
| {{convert|3|-|6|ft}}
| rowspan=2 | Input can be hyphen (-) or en&nbsp;dash (–), output uses en&nbsp;dash
|-
| data-sort-value="-" | <code>&ndash;</code>&nbsp;<code>&amp;ndash;</code> <small>(en&nbsp;dash)</small>
| <code><nowiki>{{convert|3|–|6|ft}}</nowiki></code>
| {{convert|3|–|6|ft}}
|-
| <code>and</code>
| <code><nowiki>{{convert|3|and|6|ft}}</nowiki></code>
| {{convert|3|and|6|ft}}
|
|-
| <code>and(-)</code>
| <code><nowiki>{{convert|3|and(-)|6|ft}}</nowiki></code>
| {{convert|3|and(-)|6|ft}}
| rowspan=2 | {{para|abbr|on}} abbreviates the first unit
|-
| {{nowrap|1=<code>and(-)&#x7c;abbr=on</code>}}
| {{nowrap|1=<code><nowiki>{{convert|3|and(-)|6|ft|abbr=on}}</nowiki></code>}}
| {{convert|3|and(-)|6|ft|abbr=on}}
|-
| <code>or</code>
| <code><nowiki>{{convert|3|or|6|ft}}</nowiki></code>
| {{convert|3|or|6|ft}}
|
|-
| <code>to</code>
| <code><nowiki>{{convert|3|to|6|ft}}</nowiki></code>
| {{convert|3|to|6|ft}}
|
|-
| <code>to(-)</code>
| <code><nowiki>{{convert|3|to(-)|6|ft}}</nowiki></code>
| {{convert|3|to(-)|6|ft}}
| rowspan=2 | {{para|abbr|on}} abbreviates the first unit
|-
| <code>to(-)&#x7c;abbr=on</code>
| <code><nowiki>{{convert|3|to(-)|6|ft|abbr=on}}</nowiki></code>
| {{convert|3|to(-)|6|ft|abbr=on}}
|-
| <code>to about</code>
| <code><nowiki>{{convert|3|to&nbsp;about|6|ft}}</nowiki></code>
| {{nowrap|{{convert|3|to about|6|ft}}}}
|
|-
| <code>+/-</code>
| <code><nowiki>{{convert|3|+/-|6|ft}}</nowiki></code>
| {{convert|3|+/-|6|ft}}
|
|-
| data-sort-value="+/-" | <code>±</code>&nbsp;<code>&amp;plusmn;</code>
| <code><nowiki>{{convert|3|±|6|ft}}</nowiki></code>
| {{convert|3|±|6|ft}}
|
|-
| <code>+</code>
| <code><nowiki>{{convert|3|+|6|ft}}</nowiki></code>
| {{convert|3|+|6|ft}}
|
|-
| <code>,</code>
| <code><nowiki>{{convert|3|,|6|ft}}</nowiki></code>
| {{convert|3|,|6|ft}}
|
|-
| <code>, and</code>
| <code><nowiki>{{convert|3|, and|6|ft}}</nowiki></code>
| {{nowrap|{{convert|3|, and|6|ft}}}}
|
|-
| <code>, or</code>
| <code><nowiki>{{convert|3|, or|6|ft}}</nowiki></code>
| {{convert|3|, or|6|ft}}
|
|-
| <code>by</code>
| <code><nowiki>{{convert|3|by|6|ft}}</nowiki></code>
| {{convert|3|by|6|ft}}
|
|-
| <code>x</code>
| <code><nowiki>{{convert|3|x|6|ft}}</nowiki></code>
| {{convert|3|x|6|ft}}
| rowspan=3 | {{para|abbr|on}} abbreviates ''and repeats'' the first unit
|-
| <code>&times;</code>&nbsp;<code>&amp;times;</code>
| <code><nowiki>{{convert|3|&times;|6|ft}}</nowiki></code>
| {{convert|3|&times;|6|ft}}
|-
| <code>x&#x7c;abbr=on</code>
| <code><nowiki>{{convert|3|x|6|ft|abbr=on}}</nowiki></code>
| {{convert|3|x|6|ft|abbr=on}}  
|}


===Multiple dimensions: ''{{convert|6|x|12|m|ft|abbr=on}}''===
===Multiple dimensions: ''{{convert|6|x|12|m|ft|abbr=on}}''===
Line 343: Line 222:


===Wrapping and line breaking===
===Wrapping and line breaking===
:See [[w:Help:Convert#Wrapping and line breaking]]
:See {{section link|Help:Convert|Wrapping and line breaking}}


===<span id="million"></span>Spelling out "thousands", "millions", etc.===
===<span id="million"></span>Spelling out "thousands", "millions", etc.===
Line 491: Line 370:


====In the unit: ''e6m''====
====In the unit: ''e6m''====
Engineering notation can be entered as a "prefix" to the unit:
[[Engineering notation]] can be entered as a "prefix" to the unit:
* <code><nowiki>{{convert|70|e6m}}</nowiki></code> → {{convert|70|e6m|abbr=on}}
* <code><nowiki>{{convert|70|e6m}}</nowiki></code> → {{convert|70|e6m|abbr=on}}


Line 505: Line 384:


===Scientific notation: ''1.23 × 10<sup>−14</sup>''===
===Scientific notation: ''1.23 × 10<sup>−14</sup>''===
In [[w:scientific notation|scientific notation]], a number is written like 1.23e-14. The plain number has exactly one digit before the decimal point.
In [[scientific notation]], a number is written like {{val|1.23e-14}}. The plain number has exactly one digit before the decimal point.


With {{tlf|convert}}, the input can be in e-notation such as <code>12.3e4</code>. This value is displayed as a power of ten, and the output is displayed in scientific notation, except that an output value satisfying 0.01 <= v < 1000 is shown as a normal number. In addition, if the output value is 1000 and sigfig=4 is used, the value is displayed as a normal number.
With {{tlf|convert}}, the input can be in e-notation such as <code>12.3e4</code>. This value is displayed as a power of ten, and the output is displayed in scientific notation, except that an output value satisfying 0.01 <= v < 1000 is shown as a normal number. In addition, if the output value is 1000 and sigfig=4 is used, the value is displayed as a normal number.
Line 516: Line 395:
*<code><nowiki>{{convert|1⁄2|in|mm|1}}</nowiki></code> → {{convert|1⁄2|in|mm|1}}
*<code><nowiki>{{convert|1⁄2|in|mm|1}}</nowiki></code> → {{convert|1⁄2|in|mm|1}}


With positive [[w:mixed number|mixed number]]s (a positive integer and a fraction), use a <code>+</code> sign
With positive [[mixed number]]s (a positive integer and a fraction), use a <code>+</code> sign
*<code><nowiki>{{convert|2+1⁄2|in|mm|1}}</nowiki></code> → {{convert|2+1⁄2|in|mm|1}}
*<code><nowiki>{{convert|2+1⁄2|in|mm|1}}</nowiki></code> → {{convert|2+1⁄2|in|mm|1}}


Line 527: Line 406:
*<code><nowiki>{{convert|2+½|in|mm|1}}</nowiki></code> → {{convert|2+½|in|mm|1}} {{nay}} Fractions consisting of a single Unicode character are not allowed either.
*<code><nowiki>{{convert|2+½|in|mm|1}}</nowiki></code> → {{convert|2+½|in|mm|1}} {{nay}} Fractions consisting of a single Unicode character are not allowed either.


===Horizontal fraction bar: ''{{frac|1|2}}&nbsp;inch''===
===Horizontal fraction bar: ''{{sfrac|1|2}}&nbsp;inch''===
<!-- technical restriction: TOC does not show the example horizontal bar intended here; rephrased section title-->
<!-- technical restriction: TOC does not show the example horizontal bar intended here; rephrased section title-->
Using a double slash (<code>//</code>) provides a horizontal fraction bar for the original (input) unit:
Using a double slash (<code>//</code>) provides a horizontal fraction bar for the original (input) unit:
Line 668: Line 547:


==Table options==
==Table options==
For the [[w:Help:Table/Manual tables|wikitable]] structure, there are three options: add a line-break, split the result over columns and make the table sortable.
For the [[Help:Table/Manual tables|wikitable]] structure, there are three options: add a line-break, split the result over columns and make the table sortable.


===Enforced line break===
===Enforced line break===
Line 716: Line 595:


===Sorting===
===Sorting===
Use {{para|sortable|on}} to include a ''hidden numerical sortkey'' in the output, suitable for use in a [[w:Help:Sorting|table with sortable columns]]. Technically, this places a hidden string before the actual displayed values:
Use {{para|sortable|on}} to include a ''hidden numerical sortkey'' in the output, suitable for use in a [[Help:Sorting|table with sortable columns]]. Technically, this places a hidden string before the actual displayed values:
:<code><nowiki>{{convert|10|m|ft|sortable=on}}</nowiki></code> {{nowrap|1=→ <code>&lt;span data-sort-value="7001100000000000000♠">&lt;/span>10 metres (33&nbsp;ft)</code>}}
:<code><nowiki>{{convert|10|m|ft|sortable=on}}</nowiki></code> {{nowrap|1=→ <code>&lt;span data-sort-value="7001100000000000000♠">&lt;/span>10 metres (33&nbsp;ft)</code>}}
:showing: {{convert|10|m|ft|sortable=on}}.
:showing: {{convert|10|m|ft|sortable=on}}.
Line 729: Line 608:
|-
|-
| A
| A
| <span class="nowrap"><span data-sort-value="7001157500000000000♠"></span>15.75&nbsp;m</span>
| {{val|15.75|u=m}}
| {{convert|15+3/4|m|ft|disp=table|sortable=on}}
| {{convert|15+3/4|m|ft|disp=table|sortable=on}}
|-
|-
| B
| B
| <span class="nowrap"><span data-sort-value="7001155000000000000♠"></span>15.5&nbsp;m</span>
| {{val|15.5|u=m}}
| {{convert|15.5|m|ft|disp=table|sortable=on}}
| {{convert|15.5|m|ft|disp=table|sortable=on}}
|-
|-
| C
| C
| <span class="nowrap"><span data-sort-value="7001160000000000000♠"></span>16&nbsp;m</span>
| {{val|16|u=m}}
| {{convert|16.0|m|ft|disp=table|sortable=on}}
| {{convert|16.0|m|ft|disp=table|sortable=on}}
|-
|-
| D
| D
| <span class="nowrap"><span data-sort-value="7001160000000000000♠"></span>16&nbsp;m</span>
| {{val|16|u=m}}
| {{convert|16|m|ft|disp=table|sortable=on}}
| {{convert|16|m|ft|disp=table|sortable=on}}
|}
|}
Line 748: Line 627:


==Units==
==Units==
The conversion factors and physical constants are sourced [[w:Module:Convert/documentation/conversion data introduction/doc#Conversion factors and physical constants|here]].
The conversion factors and physical constants are sourced [[Module:Convert/documentation/conversion data introduction/doc#Conversion factors and physical constants|here]].


===All units===
===All units===
See [[w:Template:Convert/list of units]]. Units are case-sensitive: use <code>kW</code>, not <code>KW</code> or <code>kw</code>
{{selfref|See also: [[Template:Convert/list of units]]}}
{{hatnote|Units are case-sensitive: use {{xt|kW}}, not {{!xt|KW}} or {{!xt|kw}}}}
{{Convert/list of units}}


==='per' units: ''kg/ha'', ''miles per gallon''<span class="anchor" id="per"></span>===
==='per' units: ''kg/ha'', ''miles per gallon''<span class="anchor" id="per"></span>===
Line 781: Line 662:
===Multiple units: ''1 ft 5 in''===
===Multiple units: ''1 ft 5 in''===
====In input====
====In input====
Base document [[w:Module:Convert/documentation/conversion data/doc#Input multiples]] lists options for ''multiple unit input'' (like <code>ft,in</code>). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
Base document {{section link|Module:Convert/documentation/conversion data/doc|Input multiples|nopage=y}} lists options for ''multiple unit input'' (like <code>ft,in</code>). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
* <code><nowiki>{{convert|1|yd|2|ft|3|in}}</nowiki></code> → {{convert|1|yd|2|ft|3|in}}
* <code><nowiki>{{convert|1|yd|2|ft|3|in}}</nowiki></code> → {{convert|1|yd|2|ft|3|in}}
* <code><nowiki>{{convert|2|ft|3|in|cm}}</nowiki></code> → {{convert|2|ft|3|in|cm}}
* <code><nowiki>{{convert|2|ft|3|in|cm}}</nowiki></code> → {{convert|2|ft|3|in|cm}}
Line 787: Line 668:


====In output====
====In output====
Available multiple-unit output options predefined, like <code>ftin</code> and <code>ydftin</code>. The full list is at [[w:Module:Convert/documentation/conversion data/doc#Output multiples]].
Available multiple-unit output options predefined, like <code>ftin</code> and <code>ydftin</code>. The full list is at {{section link|Module:Convert/documentation/conversion data/doc|Output multiples|nopage=y}}.
* <code><nowiki>{{convert|2|m|ftin}}</nowiki></code> → {{convert|2|m|ftin}}
* <code><nowiki>{{convert|2|m|ftin}}</nowiki></code> → {{convert|2|m|ftin}}
* <code><nowiki>{{convert|2|m|ft in}}</nowiki></code> → {{convert|2|m|ft in}}, using a space, returns the decimal point
* <code><nowiki>{{convert|2|m|ft in}}</nowiki></code> → {{convert|2|m|ft in}}, using a space, returns the decimal point
Line 793: Line 674:
* <code><nowiki>{{convert|2|m}}</nowiki></code> → {{convert|2|m}}
* <code><nowiki>{{convert|2|m}}</nowiki></code> → {{convert|2|m}}


See also:
* {{tl|hands}} a length used to measure horses
* {{tl|Long ton}} a weight in ton, cwt, qr and lb
<!-- todo: mention the 0-3 limits -->


===Currency per unit: ''$/mi &rarr; $/km''===
===Currency per unit: ''$/mi &rarr; $/km''===
Line 804: Line 689:
* <code><nowiki>{{convert|10|$/mi|$/km|$=€}}</nowiki></code> → {{convert|10|$/mi|$/km|$=€}}
* <code><nowiki>{{convert|10|$/mi|$/km|$=€}}</nowiki></code> → {{convert|10|$/mi|$/km|$=€}}


It is ''not'' possible to convert the currency. So, this result (mixed currencies) is ''not'' possible: $15 per mile (€8.6/km)}} {{nay}}
It is ''not'' possible to convert the currency. So, this result (mixed currencies) is ''not'' possible: {{!mxt|1=$15 per mile (€8.6/km)}} {{nay}}


==Using convert inside templates==
For usage in template code, like infoboxes, {{tlf|Convert}} has these options:
;Pre-formatting fraction input
* [[Module:Convert/helper]] can read regular input and pre-format it into {{tlf|Convert}}-accepted input.
:Your template can accept {{para|input|16 7/8}} and use <nowiki>{{#invoke:Convert/helper|number|16 7/8}}</nowiki> &rarr; {{#invoke:Convert/helper|number|16 7/8}}
;Using a Wikidata property
* Adding the Wikidata property code, like code {{para|input|P2073}}, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an ''other'' article, use {{para|qid}}.
Example for {{Wikidata property link|P2073}} of {{Wikidata entity link|{{get QID|Cessna 208 Caravan}}}}:
* <code><nowiki>{{convert|input=P2073|qid={{get QID|Cessna 208 Caravan}}|ftin|abbr=on}}</nowiki></code>  &rarr; {{convert|input=P2073|qid={{get QID|Cessna 208 Caravan}}|ftin|abbr=on}}
* <code><nowiki>{{convert|input=P2073|qid=Q1056131|km|abbr=on}}</nowiki></code>  &rarr; {{convert|input=P2073|qid=Q1056131|km|abbr=on}}
* <code><nowiki>{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}</nowiki></code>  &rarr; {{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
:For example see [[template:Infobox Telescope]].
Sometimes a property may have more than one value against it in Wikidata. You can use the {{para|qual}} parameter to specify which of the values you want to use.
Example for {{Wikidata property link|P2386}}:
Note: this example uses {{para|qid|Q1513315}} (testing for {{Wikidata entity link|Q1513315}})
* {{Wikidata entity link|Q613628}}: <code><nowiki>{{convert|input=P2386|qual=Q613628|ft|abbr=on}}</nowiki></code> → {{convert|input=P2386|qid=Q1513315|qual=Q613628|ft|abbr=on}}
* {{Wikidata entity link|Q1395645}}: <code><nowiki>{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}</nowiki></code> → {{convert|input=P2386|qid=Q1513315|qual=Q1395645|ft|abbr=on}}


==Parameter list==
==Parameter list==
{| class="wikitable sortable collapsible uncollapsed" style="width:100%;"
{{convert/doc/parameter list}}
! colspan=4 style="background:#eee" | '''Parameter options for <nowiki>{{convert}}</nowiki>'''
|-
! Parameter
! Value
! Description
! Note
|-
|<code>&#124;abbr=in</code> || data-sort-value="in" | <code>in</code>
| Use symbol for first (left-hand side) unit
| Unit display
|-
|<code>&#124;abbr=off</code> || data-sort-value="off" | <code>off</code>
| rowspan=2 | Use name for all units
| rowspan=2 | Unit display
|-
|<code>&#124;abbr=none</code> || data-sort-value="none" | <code>none</code>
|-
|<code>&#124;abbr=on</code> || data-sort-value="on" | <code>on</code>
| Use symbol for all units
| Unit display
|-
|<code>&#124;abbr=out</code> || data-sort-value="out" | <code>out</code>
| Use symbol for right-hand side unit (default)
| Unit display
|-
|<code>&#124;abbr=unit</code> || data-sort-value="unit" | <code>unit</code>
| Use symbol for all units when using scientific notation
| Unit display
|-
|<code>&#124;abbr=values</code> || data-sort-value="values" | <code>values</code>
| Omit both the input and output units: show only the numbers
| Unit display
|-
|<code>&#124;abbr=~</code> || data-sort-value="~" | <code>~</code>
| Shows both unit name and symbol
| Unit display
|-
|<code>&#124;adj=mid&#124;…</code> || data-sort-value="mid" | <code>mid</code>
| User-specified text after the input unit; sets <code>adj=on</code> (adjective). Expects 1 unnamed parameter.
| Word adding, adjective
|-
|<code>&#124;adj=on</code> || data-sort-value="on" | <code>on</code>
| Unit name is adjective (singular and hyphenated)
| Grammar, adjective
|-
|<code>&#124;adj=pre&#124;…</code> || data-sort-value="pre" | <code>pre</code>
| User-specified text before input unit. Expects 1 unnamed parameter.
| Word adding
|-
|<code>&#124;adj=ri0</code> || data-sort-value="ri0" | <code>ri0</code>
| Round input with precision 0
| Input precision
|-
|<code>&#124;adj=ri1</code> || data-sort-value="ri1" | <code>ri1</code>
| Round input with precision 1
| Input precision
|-
|<code>&#124;adj=ri2</code> || data-sort-value="ri2" | <code>ri2</code>
| Round input with precision 2
| Input precision
|-
|<code>&#124;adj=ri3</code> || data-sort-value="ri3" | <code>ri3</code>
| Round input with precision 3
| Input precision
|-
|<code>&#124;comma=5</code> || data-sort-value="05" | <code>5</code>
| Only use comma for thousands separator if 5 or more digits
| Number format
|-
|<code>&#124;comma=gaps</code> || data-sort-value="gaps" | <code>gaps</code>
| Use gaps (space), not comma, for thousands separator
| Number format
|-
|<code>&#124;comma=off</code> || data-sort-value="off" | <code>off</code>
| No thousands separator
| Number format
|-
|<code>&#124;disp=b</code> || data-sort-value="b" | <code>b</code>
| Join input and output using "&nbsp;(...)" (default)
| Join values
|-
|<code>&#124;disp=sqbr</code> || data-sort-value="sqbr" | <code>sqbr</code>
| Join input and output using "&nbsp;[...]"
| Join values
|-
|<code>&#124;disp=br</code> || data-sort-value="br" | <code>br</code>
| Join input and output using "&lt;br/>"
| Join values
|-
|<code>&#124;disp=comma</code> || data-sort-value="comma" | <code>comma</code>
| Join input and output using ",&nbsp;"
| Join values
|-
|<code>&#124;disp=or</code> || data-sort-value="or" | <code>or</code>
| Join input and output using "&nbsp;or&nbsp;"
| Join values
|-
|<code>&#124;disp=number</code> || data-sort-value="number" | <code>number</code>
| rowspan=2 | Display output number only
| rowspan=2 | Parts only
|-
|<code>&#124;disp=output number only</code> || data-sort-value="output number only" | <code>output number only</code>
|-
|<code>&#124;disp=out</code> || data-sort-value="out" | <code>out</code>
| rowspan=2 | Display only output number and name/symbol
| rowspan=2 | Parts only
|-
|<code>&#124;disp=output only</code> || data-sort-value="output only" | <code>output only</code>
|-
|<code>&#124;disp=preunit&#124;…[&#124;…]</code> || data-sort-value="preunit" | <code>preunit</code>
| Text to be inserted after value and before units, for both input and output, with optionally different text for output.  Expects 1 or 2 unnamed parameters.
| Word adding
|-
|<code>&#124;disp=table</code> || data-sort-value="table" | <code>table</code>
| Output is suitable for a table cell with align="right"
| Table columns
|-
|<code>&#124;disp=tablecen</code> || data-sort-value="tablecen" | <code>tablecen</code>
| Output is suitable for a table cell with align="center"
| Table columns
|-
|<code>&#124;disp=unit</code> || data-sort-value="unit" | <code>unit</code>
| Display input name/symbol only (not input number, not output)
| Parts only
|-
|<code>&#124;disp=unit2</code> || data-sort-value="unit2" | <code>unit2</code>
| Display output name/symbol only (not input; not output number)
| Parts only
|-
|<code>&#124;disp=x&#124;…</code> || data-sort-value="x" | <code>x</code>
| Join input and output using user-specified text
| Word adding
|-
|<code>&#124;frac=''N''</code> || data-sort-value="N" | <code>''N''</code>
| Show imperial number in fractions, denominator=''N''
| Number format, fraction
|-
|<code>&#124;lk=in</code> || data-sort-value="in" | <code>in</code>
| Link left-hand side unit name or symbol
| Unit link
|-
|<code>&#124;lk=on</code> || data-sort-value="on" | <code>on</code>
| Link all unit names or symbols (but not twice for the same unit)
| Unit link
|-
|<code>&#124;lk=out</code> || data-sort-value="out" | <code>out</code>
| Link right-hand side unit name or symbol
| Unit link
|-
|<code>&#124;order=flip</code> || data-sort-value="flip" | <code>flip</code>
| Inverts order of input, output measurements (conversion first)
| Order
|-
|<code>&#124;order=out</code> || data-sort-value="out" | <code>out</code>
| Displays output units in the order entered, skipping input unit
| Order
|-
|<code>&#124;round=5</code> || data-sort-value="05" | <code>5</code>
| Rounds calculation to the nearest multiple of 5
| Output precision
|-
|<code>&#124;round=25</code> || data-sort-value="25" | <code>25</code>
| Rounds calculation to the nearest multiple of 25
| Output precision
|-
|<code>&#124;round=each</code> || data-sort-value="each" | <code>each</code>
| In a range, each number is rounded by the default rounding
| Output precision
|-
|<code>&#124;sigfig=''N''</code> || data-sort-value="N" | <code>''N''</code>
| Round output number to ''N'' significant figures (''N'' is a positive integer)
| Output precision
|-
|<code>&#124;sortable=on</code> || data-sort-value="on" | <code>on</code>
| Adds invisible sort key
| Table sort
|-
|<code>&#124;sp=us</code> || data-sort-value="us" | <code>us</code>
| Use U.S. spelling ("meter" instead of default "metre")
| Spelling U.S.&nbsp;names
|-
|<code>&#124;spell=in</code> || data-sort-value="in" | <code>in</code>
| Spell input number in words
| Spelling numbers
|-
|<code>&#124;spell=In</code> || data-sort-value="In" | <code>In</code>
| Spell input number in words with first letter uppercase
| Spelling numbers
|-
|<code>&#124;spell=on</code> || data-sort-value="on" | <code>on</code>
| Spell input and output numbers in words
| Spelling numbers
|-
|<code>&#124;spell=On</code> || data-sort-value="On" | <code>On</code>
| Spell input and output numbers in words with first letter uppercase
| Spelling numbers
|-
|<code>&#124;$=&euro;</code> || data-sort-value="&euro;" | <code>&euro;</code>
| Replace $-sign with a currency sign, for example in <code>&euro;/hectare</code>
| Cost per unit<br /> {{nowrap|No currency conversion happens}}
|-
|<code>&#124;debug=yes</code> || data-sort-value="yes" | <code>yes</code>
| '''Debugging only'''. In a sortable table: show the normally hidden sort key
| Table sort


|}
==Deprecated options==
{{Convert/doc/deprecations list}}


==TemplateData==
{{TemplateData header}}


==TemplateData==
<templatedata>
<templatedata>
{
{
Line 1,322: Line 1,027:
}
}
</templatedata>
</templatedata>
<!--''to be added''
==Glossary==
;unit code
:
;unit symbol
:
-->


<includeonly>
==See also==
* {{tl|Cvt}}
* {{tl|SI units}}
* {{tl|Inflation}}, for converting historical prices to their current equivalent
* {{tl|To USD}}, for currency conversions
{{Convert/documentation navbox}}
<noinclude>
[[Category:Templates]]
[[Category:Templates]]
</includeonly>
}}}}</includeonly>
Please note that all contributions to skyHow are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) (see skyHow:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)