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}} | ||
'''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]]. | |||
'''{{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 [[ | |||
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 [[ | {{hatnote|See [[Help:Convert]] for more detailed, technical information}} | ||
==Units to convert== | ==Units to convert== | ||
{{hatnote|See also: the summary at [[ | {{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'' ''into'': | Enter units to convert ''from'' ''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}} | ||
:[[ | :[[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|§ 'per' units: kg/ha]] and [[#Currency per unit: $/mi → $/km|§ Currency per unit: $/km]]) | :For "per" units, use "/" (slash): kg/ha (see [[#'per'_units:_kg/ha,_miles_per_gallon|§ 'per' units: kg/ha]] and [[#Currency per unit: $/mi → $/km|§ 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 m'' or ''30.5 m'' or ''30.48 m''?<span class="anchor" id="Rounding"></span>== | ==Rounding: ''100 ft'' is ''30 m'' or ''30.5 m'' or ''30.48 m''?<span class="anchor" id="Rounding"></span>== | ||
{{hatnote|See | {{hatnote|See {{section link|Help:Convert#Rounding}} for a more mathematical description of the rounding options}} | ||
By definition, 100 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 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|<some positive integer>}}. ([[ | Specify the desired ''denominator'' using {{para|frac|<some positive integer>}}. ([[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 145: | Line 144: | ||
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. | 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}}: | Result (1) seems off until you set the [[significant figures]] yourself with {{para|sigfig}}: | ||
:{{#invoke:DemoTemplate|convert|10000|C|sigfig=5}} | :{{#invoke:DemoTemplate|convert|10000|C|sigfig=5}} | ||
or you set the precision ''positionally'', relative to the decimal point (zero being ''at'' the decimal point): | or you set the precision ''positionally'', relative to the decimal point (zero being ''at'' the decimal point): | ||
Line 176: | Line 175: | ||
See also: | See also: | ||
* For multiple-unit options like ''1 ft 5 in'', see | * 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== | ||
{{ | {{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. | ||
Line 286: | Line 285: | ||
| <code><nowiki>{{convert|3|x|6|ft|abbr=on}}</nowiki></code> | | <code><nowiki>{{convert|3|x|6|ft|abbr=on}}</nowiki></code> | ||
| {{convert|3|x|6|ft|abbr=on}} | | {{convert|3|x|6|ft|abbr=on}} | ||
|- class="sortbottom"<!--deprecated--> | |||
| <code>xx</code> | |||
| colspan=3 | {{!mxt|1=|xx|}} is '''deprecated'''. Use {{mxt|1=|x|}} instead | |||
|- class="sortbottom"<!--deprecated--> | |||
| <code>*</code> | |||
| colspan=3 | {{!mxt|1=|*|}} is '''deprecated'''. Use {{mxt|1=|x|}} instead | |||
|} | |} | ||
Line 343: | Line 348: | ||
===Wrapping and line breaking=== | ===Wrapping and line breaking=== | ||
:See | :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 505: | Line 510: | ||
===Scientific notation: ''1.23 × 10<sup>−14</sup>''=== | ===Scientific notation: ''1.23 × 10<sup>−14</sup>''=== | ||
In [[ | 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 521: | ||
*<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 [[ | 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 532: | ||
*<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: ''{{ | ===Horizontal fraction bar: ''{{sfrac|1|2}} 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 673: | ||
==Table options== | ==Table options== | ||
For the [[ | 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 721: | ||
===Sorting=== | ===Sorting=== | ||
Use {{para|sortable|on}} to include a ''hidden numerical sortkey'' in the output, suitable for use in a [[ | 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><span data-sort-value="7001100000000000000♠"></span>10 metres (33 ft)</code>}} | :<code><nowiki>{{convert|10|m|ft|sortable=on}}</nowiki></code> {{nowrap|1=→ <code><span data-sort-value="7001100000000000000♠"></span>10 metres (33 ft)</code>}} | ||
:showing: {{convert|10|m|ft|sortable=on}}. | :showing: {{convert|10|m|ft|sortable=on}}. | ||
Line 729: | Line 734: | ||
|- | |- | ||
| A | | A | ||
| | | {{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 | ||
| | | {{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 | ||
| | | {{val|16|u=m}} | ||
| {{convert|16.0|m|ft|disp=table|sortable=on}} | | {{convert|16.0|m|ft|disp=table|sortable=on}} | ||
|- | |- | ||
| D | | D | ||
| | | {{val|16|u=m}} | ||
| {{convert|16|m|ft|disp=table|sortable=on}} | | {{convert|16|m|ft|disp=table|sortable=on}} | ||
|} | |} | ||
Line 748: | Line 753: | ||
==Units== | ==Units== | ||
The conversion factors and physical constants are sourced [[ | 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 [[ | {{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 788: | ||
===Multiple units: ''1 ft 5 in''=== | ===Multiple units: ''1 ft 5 in''=== | ||
====In input==== | ====In input==== | ||
Base document | 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 794: | ||
====In output==== | ====In output==== | ||
Available multiple-unit output options predefined, like <code>ftin</code> and <code>ydftin</code>. The full list is at | 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 800: | ||
* <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 → $/km''=== | ===Currency per unit: ''$/mi → $/km''=== | ||
Line 804: | Line 815: | ||
* <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> → {{#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> → {{convert|input=P2073|qid={{get QID|Cessna 208 Caravan}}|ftin|abbr=on}} | |||
* <code><nowiki>{{convert|input=P2073|qid=Q1056131|km|abbr=on}}</nowiki></code> → {{convert|input=P2073|qid=Q1056131|km|abbr=on}} | |||
* <code><nowiki>{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}</nowiki></code> → {{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== | ||
{{convert/doc/parameter list}} | |||
==Deprecated options== | |||
{{Convert/doc/deprecations list}} | |||
==TemplateData== | |||
{{TemplateData header}} | |||
<templatedata> | <templatedata> | ||
{ | { | ||
Line 1,322: | Line 1,153: | ||
} | } | ||
</templatedata> | </templatedata> | ||
<!--''to be added'' | |||
==Glossary== | |||
;unit code | |||
: | |||
;unit symbol | |||
: | |||
--> | |||
==See also== | |||
* {{tl|Cvt}} | |||
* {{tl|SI units}} | |||
* {{tl|Inflation}}, for converting historical prices to their current equivalent | |||
* {{tl|To USD}}, for currency conversions | |||
<includeonly> | <includeonly> | ||
[[Category:Templates]] | [[Category:Templates]] | ||
</includeonly> | </includeonly> |