Difference between revisions of "Template:Convert/doc"

From Teampedia
Jump to: navigation, search
 
Line 1: Line 1:
=== Usage ===
+
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->
This template can be used to show measurement quantities as primary and converted secondary units (or ranges), with optional rounding, wikilinks, abbreviation, or US spellings, and various separators including:&nbsp; parentheses, slash, "or", hyphens, comma, "to" or dashes. Styles include: distance "{{convert|32.0|m|ft}}" and "{{convert|32.0|m|ft|disp=or}}"; temperature "{{convert|18|°C|°F}}" or "{{convert|18|°C|°F|disp=s}}"; weight "{{convert|55.0|kg|lb|abbr=on}}" or "{{convert|65|to|80|kg|lb|abbr=on}}"; etc. For units see: [[Template:Convert/list of units|Convert/list of units]].
+
__NOTOC__
{|
+
==Purpose==
|- bgcolor="#FAFEFF" valign=top
+
|Options&nbsp;include:&nbsp;||[[#lk_in|<code>lk=in</code>]], [[#abbr_on|<code>abbr=on</code>]], [[#sp_us|<code>sp=us</code>]], [[#adj_on|<code>adj=on</code>]], [[#disp_or|<code>disp=or</code>]], [[#disp_table|<code>disp=table</code>]] and [[#sortable_on|<code>sortable=on</code>]] (explained below). By default, output is [[#Rounding|rounded]] to match the precision of input; alternatives include: <code>sigfig=3</code> or using the end parameter, e.g. appending <code>-2</code> to show full hundreds.
+
|}
+
'''Single value''':
+
<tt><nowiki>{{</nowiki>convert|''original_value''|''original_unit''|''conversion_unit''|''round_to''<nowiki>|...}}</nowiki></tt>
+
  
'''Range of values''' (see below for list of ''range'' options):
+
To show quantities in a primary and secondary display, such as {{convert|32|m|ft|1}}, or {{convert|18|°C|°F|1}}.
<tt><nowiki>{{</nowiki>convert|''orig_val1''|''range''|orig_val2|''original_unit''|''conversion_unit''|''round_to''<nowiki>|...}}</nowiki></tt>
+
  
* Numbers must be entered in unformatted form (without commas). For negative numbers (i.e. temperatures or precision) use a hyphen as the minus sign for the input number.  Values output by the template will be displayed formatted and with a true minus sign where appropriate. To specify with commas, re-code a number as <nowiki>{{formatnum:9,000,500|R}}</nowiki> (becomes 9000500).
+
== Usage ==
* Optional parameters, in examples below, allow abbreviated units (abbr=on), or US spellings (sp=us for ''meter''), or slash separation (disp=s), or hyphenation (adj=on), etc.
+
  <tt><nowiki>{{</nowiki>convert|''original_value''|''original_unit''|''conversion_unit''|''round_to''<nowiki>}}</nowiki></tt>
* For this template many levels of [[Wikipedia:Template substitution|substitution]] are possible, hence doing this fully, step by step, is cumbersome, use [[Special:ExpandTemplates]] instead.
+
* The template has no in-built capacity for [[dimensional analysis]].  It is therefore up to the user to ensure that the input and output units are compatible.  Do not, for example, attempt to convert barrels to tonnes (but see {{tl|bbl to t}}).  Also beware of units with similar names; the code <code>oz</code>, for example, is for the avoirdupois ounce (a unit of mass), do not use this if you want fluid ounces.
+
* An attempt to convert a unit to itself (e.g. km to km), will result in a template loop.
+
* The range functionality is not fully implemented for all units, so experimentation may be required.
+
* This documentation page tends to lag behind in terms of what the template can do.  For details see the talk page and its archives.
+
  
===Examples===
+
== Examples ==
====Single value====
+
 
{| class="wikitable"
 
{| class="wikitable"
 
|'''Input'''||'''Displays as'''
 
|'''Input'''||'''Displays as'''
 
|-
 
|-
|<nowiki>{{convert|3.21|kg|lb}}</nowiki>||{{convert|3.21|kg|lb}}
+
|<nowiki>{{convert|32|m|ft|0}}</nowiki>||{{convert|32|m|ft|0}}
 
|-
 
|-
|<nowiki>{{convert|3.21|kg|lb|0}}</nowiki>||{{convert|3.21|kg|lb|0}}
+
|<nowiki>{{convert|18|°C|°F|1}}</nowiki>||{{convert|18|°C|°F|1}}
 
|-
 
|-
|<nowiki>{{convert|10|kg |lb |disp=or}}</nowiki>||{{convert|10|kg |lb |disp=or}}
+
|<nowiki>{{convert|10|mi|km|0}}</nowiki>||{{convert|10|mi|km|0}}
 
|-
 
|-
|<nowiki>{{convert|6|ft|5|in|m}}</nowiki>||{{convert|6|ft|5|in|m}}
+
|<nowiki>{{convert|25|km|mi|0}}</nowiki>||{{convert|25|km|mi|0}}
<!--This is currently broken, see talk page
+
 
|-
 
|-
|<nowiki>{{convert|2|m|ftin}}</nowiki>||{{convert|2|m|ftin}}
+
|<nowiki>{{convert|1|lb|kg|0}}</nowiki>||{{convert|1|lb|kg|0}}
-->
+
 
|-
 
|-
|<nowiki>{{convert|10|mi}}</nowiki>||{{convert|10|mi}}
+
| <nowiki>{{convert|1250|sqft|sqm|1|lk=on}}</nowiki> ||{{convert|1250|sqft|sqm|1|lk=on}} 
 +
|-
 +
|<nowiki>{{convert|20.5|sqkm|sqmi|1|lk=on|abbr=on}}</nowiki>||{{convert|20.5|sqkm|sqmi|1|lk=on|abbr=on}}
 
|-
 
|-
|<nowiki>{{convert|100|mpgus}}</nowiki>||{{convert|100|mpgus}}
+
|<nowiki>{{convert|641|acre|sqmi|3|lk=on|abbr=on}}</nowiki>||{{convert|641|acre|sqmi|3|lk=on|abbr=on}}
 
|-
 
|-
|<nowiki>{{convert|120|km/h}}</nowiki>||{{convert|120|km/h}}
+
|''However''||
 
|-
 
|-
|<nowiki>{{convert|18|°C|°F}}</nowiki>||{{convert|18|°C|°F}}
+
|<nowiki>{{convert|641|acre|sqmi|2|lk=on|abbr=on}}</nowiki>||{{convert|641|acre|sqmi|2|lk=on|abbr=on}} because 640 acres equals one square mile; 641 acres rounded to 2 would equal 1.00&nbsp;sq&nbsp;mi.  Therefore it is displayed as 1&nbsp;sq&nbsp;mi.
|-
+
| <nowiki>{{convert|1250|sqft|m2|lk=in|sigfig=2}}</nowiki> ||{{convert|1250|sqft|m2|lk=in|sigfig=2}}<br/>Note 'lk=in' links only the input unit. This example is for illustration only, common units of measurement should not be linked. See: [[Wikipedia:Only make links that are relevant to the context|wp:overlink]].
+
|-
+
|<nowiki>{{convert|20.5|m3|cuyd|lk=out|abbr=on}}</nowiki>||{{convert|20.5|m3|cuyd|1|lk=out|abbr=on}}<br/>Note 'lk=out' links only the output unit, [[cu yd]].
+
|-
+
|<nowiki>{{convert|641|acre|km2 sqmi|lk=on}}</nowiki>||{{convert|641|acre|km2 sqmi|lk=on}}<br/>Note 'lk=on' links all units. Per guidelines, common units should not be linked. See: [[Wikipedia:Only make links that are relevant to the context|wp:overlink]].
+
|-
+
|<nowiki>{{convert|641|acre|km2 sqmi|2|lk=on}}</nowiki>||{{convert|641|acre|km2 sqmi|2|lk=on}}<br/> Although 640 acres equals 1 square mile; 641 acres rounded to two decimal places equals 1.00&nbsp;sq&nbsp;mi.
+
 
|}
 
|}
  
====Range of values====
+
===Tricks===
:''Note: not yet operational for all units''
+
 
{| class="wikitable"
 
{| class="wikitable"
|'''Input'''||'''Displays as'''
 
 
|-
 
|-
|<nowiki>{{convert|60|and|170|kg|lb}}</nowiki>||{{convert|60|and|170|kg|lb}}
+
! colspan="2" | <big>'''In order to...'''</big>
 
|-
 
|-
|<nowiki>{{convert|60|to|170|kg|lb}}</nowiki>||{{convert|60|to|170|kg|lb}}
+
| Use [[United States|U.S.]] spelling || attach <code><nowiki>|sp=us</nowiki></code>
 
|-
 
|-
|<nowiki>{{convert|60|to(-)|170|kg|lb}}</nowiki>||{{convert|60|to(-)|170|kg|lb}}
+
| Make units [[Wikipedia:Manual of Style (links)|wikilinked]] || attach <code><nowiki>|lk=on</nowiki></code> (The [[WP:MOS|manual of style]] suggests that you only link the first instance).
 
|-
 
|-
|<nowiki>{{convert|60|-|170|kg|lb}}</nowiki>||{{convert|60|-|170|kg|lb}}
+
| Use the singular for grammar || attach <code><nowiki>|sing=on</nowiki></code> (ex: "The 190 foot (58 m) bridge" as opposed to "feet")
 
|-
 
|-
|<nowiki>{{convert|41|to|50|F|C}}</nowiki>||{{convert|41|to|50|F|C}}
+
| Abbreviate all units || attach <code><nowiki>|abbr=on</nowiki></code>
 
|-
 
|-
|<nowiki>{{convert|41|-|50 |F|K}}</nowiki>||{{convert|41|-|50 |F|K}}
+
| Use a / instead ( ) || attach <code><nowiki>|disp=slash</nowiki></code> (or shorthand: <code><nowiki>|disp=/</nowiki></code>) (ex: 190&nbsp;foot/58&nbsp;m)
|-
+
|}
|<nowiki>{{convert|60|by|120|m|ft}}</nowiki>||{{convert|60|by|120|m|ft}}
+
|-
+
|<nowiki>{{convert|60|x|120|m|ft}}</nowiki>||{{convert|60|x|120|m|ft}}
+
|-
+
|<nowiki>{{convert|60|+/-|10|m|ft}}</nowiki>||{{convert|60|+/-|10|m|ft}}
+
|-
+
|<nowiki>{{convert|19|to|27|L|USgal}}</nowiki>||{{convert|19|to|27|L|USgal}}
+
|-
+
|<nowiki>{{convert|5|to|7|L|USgal|abbr=mos}}</nowiki>||{{convert|5|to|7|L|USgal|abbr=mos}}
+
|-
+
|<nowiki>{{convert|4|-|9|L|USgal|abbr=none}}</nowiki>||{{convert|4|-|9|L|USgal|abbr=none}}
+
|}<!--NOTE: rows require "nowiki", using &#123;{ disappears. -->
+
  
The following conversions are currently not available as a range of values:
+
===Rounding===
*Some imperial and US gallon-based units
+
The number given for rounding rounds off the result to the power of 1/10 the rounding number.  For instance, if the result is 8621 and the round number is '-2', the result will be 8600.  If the result is '234.0283043' and the round number is '0', the result will be 234.
*Fuel consumption units (mpg, L/100km)<!-- except with <code>|abbr=on</code> no links and default <code>|disp=</code> -->
+
*Large scale units (e3, e6, e9)
+
*Combination-based units (ft&in, st&lb, lb&oz) due to complexity of the conversion
+
  
===Parameters===
+
== Conversions ==
 +
The abbreviations to the right of the units are the abbreviations that can be entered when using the template.  Through various revisions of this template, some units have incorporated multiple abbreviations to make the code more flexible for editors, e.g. °F ''or'' F may be entered.    Though they may not be the correct abbreviations, the ''correct abbreviation'' will always be displayed when you use {{tl|convert}}.
 +
----
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! colspan="2" | Parameters
+
! colspan="5" | <big>Units supported by {{tl|convert}}</big>
 
|-
 
|-
| {{anchor|sp_us}}Use [[United States|US]] spelling || attach <code><nowiki>|sp=us</nowiki></code>
+
| '''system''' || '''unit''' || '''abbreviation ''used in coding'''''<br> (alternative abbreviations) || '''abbreviation ''printed''''' || [[Image:Flag of the United States.svg|20px]] '''US spelling''' <code><nowiki>|sp=us</nowiki></code>
 
|-
 
|-
| {{anchor|lk_in}}Make units [[Wikipedia:Manual of Style (links)|wikilinked]] || attach <code><nowiki>|lk=on</nowiki></code> &nbsp; to link all units{{in5|31}}(default: <tt>lk=off</tt>)<br> attach <code><nowiki>|lk=in</nowiki></code> &nbsp; to link only the input units<br> attach <code><nowiki>|lk=out</nowiki></code>&nbsp; to link only the output units<br>(The [[Wikipedia:Only make links that are relevant to the context|manual of style]] suggests that you should not link common units of measurement).
+
! colspan="5" style="font-size: 110%; text-align: left;" | '''Area'''
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | '''[[International System of Units|SI]]''' || [[square metre]] || sqm || m² || square meter
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | → || [[square kilometre]] || sqkm || km² || square kilometer
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | '''[[Imperial system|Imperial]] & [[United States customary units|U.S.&nbsp;Customary]]''' || [[acre]] || acre || acre (or acres) ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[square foot]] ||sqft || sq&nbsp;ft ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[square yard]] ||sqyd || sq&nbsp;yd ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[square mile]] || sqmi || sq&nbsp;mi ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[square nautical mile]] || sqnmi || sq&nbsp;nmi ||
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | '''old metric''' || [[hectare]] || ha || ha ||
 
|-
 
|-
| {{anchor|adj_on}}Use the adjective form || attach <code><nowiki>|adj=on</nowiki></code> (e.g. "The 190-foot (58 m) bridge" as opposed to "The 190 feet..."). This produces the adjective form—the unit name in the singular with a hyphen (according to the [[WP:HYPHEN|Manual of Style]]).
+
! colspan="5" style="font-size: 110%; text-align: left;" | '''Length'''
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | '''SI''' || [[millimetre]] || mm || mm || millimeter
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | → || [[centimetre]] || cm || cm || centimeter
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | → || [[metre]] || m || m || meter
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | → || [[kilometre]] || km || km || kilometer
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | '''Imperial & U.S.&nbsp;Customary''' || [[inch]] || in || in ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[foot (unit of length)|foot]] || ft || ft ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[yard]] || yd || yd ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[mile]] || mi || mi ||
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | → || [[nautical mile]] || nmi || nmi ||
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | '''Other''' || [[astronomical unit]] || AU || AU ||
 
|-
 
|-
| {{anchor|abbr_on}}Abbreviate units, or none || attach <code><nowiki>|abbr=on</nowiki></code>{{in5|7}}to show unit symbols{{in5|10}}(default: <tt>abbr=off</tt>)<br> attach <code><nowiki>|abbr=none</nowiki></code> &nbsp; to show all units in full words<br> attach <code><nowiki>|abbr=in</nowiki></code> {{in5}} to abbreviate input units<br> attach <code><nowiki>|abbr=out</nowiki></code>{{in5}}to abbreviate output units.
+
! colspan="5" style="font-size: 110%; text-align: left;" | '''Speed'''
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | '''SI''' || [[metres per second]] || m:s (m/s) || m/s || meter per second
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | → || [[kilometres per hour]] || km:h (km/h ''or'' kph)|| km/h || kilometer per hour
 +
|- style="font-size: 90%; background-color: #FFFFFF;"
 +
| style="text-align: center;" | '''Accepted ''non''-SI''' || [[knot (speed)|knot]] || knot || kt ||
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | '''Imperial & U.S.&nbsp;Customary''' || [[feet per second]] || ft:s (ft/s) || ft/s ||
 +
|- style="font-size: 90%;"
 +
| style="text-align: center;" | → || [[miles per hour]] || mi:h (mph ''or'' mi/h) || mph ||
 
|-
 
|-
| Change display option from "( )" || attach <code>&#124;disp=comma</code>{{in5|4}}to put comma, not parentheses<br> attach <code>&#124;disp=or</code>{{in5|10}}to put "or" between units<br> attach <code>&#124;disp=s</code> (or  <code><nowiki>|disp=/</nowiki></code>) for slash (e.g. 190&nbsp;foot/58&nbsp;metre). The default value is:&nbsp; disp=b for parentheses.
+
! colspan="5" style="font-size: 110%; text-align: left;" | '''Temperature'''
|-
+
|- style="font-size: 90%;"
| Display output only || attach <code>&#124;disp=output only</code> {{in5|15}} to show result number & unit<br> attach <code>&#124;disp=output number only</code>{{in5|3}}to show just number<br>Note when using "disp=output only" then the unit name can still be shown as full words by abbr=none, or linked by lk=on.
+
| style="text-align: center;" | '''SI''' || [[kelvin]] || K || K ||
|-
+
|- style="font-size: 90%;"
| Display unit name (only) || attach <code>&#124;disp=unit</code> {{in5|7}} to show the unit name for a symbol<br>The unit name will be plural when the amount is not 1, or hyphenated when adj=on. So, <nowiki>{{convert|2|cuyd|disp=unit}}</nowiki> shows "cubic yards" plural.
+
| style="text-align: center;" | || [[degrees Celsius]] || °C (C) || °C ||
|-
+
|- style="font-size: 90%; background-color: #FFFFFF;"
| {{anchor|disp_table}}Display amounts as table cells || attach <tt>&#124;disp=table</tt> (or <tt>&#124;disp=tablecen</tt>) Note: For use in tables, the template must start on a new line after a pipe.  Only the number will be displayed unless you set <code><nowiki>|abbr=on</nowiki></code>, <code><nowiki>|lk=on</nowiki></code>, <code><nowiki>|lk=in</nowiki></code> or <code><nowiki>|lk=out</nowiki></code>. Example: [[Phnom_Penh#Highways_in_Phnom_Penh|here]]
+
| style="text-align: center;" | '''Imperial & U.S.&nbsp;Customary''' || [[degrees Rankine]] || °R (R) || °R ||
|-
+
|- style="font-size: 90%; background-color: #FFFFFF;"
| Round to a specified number of significant figures|| attach <code><nowiki>|sigfig={some non-negative integer}</nowiki></code>. In the case of temperatures Celsius or Fahrenheit this refers to the difference with the absolute-zero temperature. For example, at room temperature two significant digits means rounded to tens of degrees.
+
| style="text-align: center;" | → || [[degrees Fahrenheit]] || °F (F) || °F ||
|-
+
| Let ''Convert'' decide the unit to convert to|| skip the ''convert to'' parameter (which would otherwise be third unnamed parameter) e.g. <code><nowiki>{{convert|100|mi|0}}</nowiki></code> gives ''{{convert|100|mi|0}}''.
+
|-
+
|Display input value as a fraction<br/>(still in prototype stage: limited functionality)|| <nowiki>{{convert|3/8|in|mm|3|abbr=on}}</nowiki><font color=blue>'''→'''</font> {{convert|3/8|in|mm|3|abbr=on}} or <nowiki>{{convert|11+1/4|in|cm|2|abbr=on}}</nowiki><font color=blue>''''''</font>{{convert|11+1/4|in|cm|2|abbr=on}}
+
|-
+
|{{anchor|sortable_on}}Generate a [[Help:Sorting#Sorting with hidden sortkey|hidden sort key]] for use with a [[Help:Sorting|sortable table]]|| attach <code><nowiki>|sortable=on</nowiki></code> to generate a [[Help:Sorting#Sorting with hidden sortkey|hidden sort key]] (in the form of <code><nowiki><span style="display:none">00000005</span></nowiki></code>) so that [[Help:Sorting|sortable tables]] will sort correctly. This takes the first numeric value and left pads it with zeros to 16 places. It ignores any additional values, ie, if you use <code>6|ft|2|in</code> as the value, it will only use the 6 for the sort key. This will cause numeric values to sort in numeric order, ie: 5, 10, 15 instead of 10, 15, 5.
+
 
|}
 
|}
  
====Parameters still under construction====
+
==Example/monitor page==
{| class="wikitable"
+
Monitor quality or look at examples at [[Template:Convert/check]]
|-
+
! colspan="2" | Parameters still under construction.  May not work in all situations
+
|-
+
|disp=tablecen||Similar to disp=table except that the values with be centered within the column.  See the tables at [[La Nouvelle branch]] for in use examples.
+
|-
+
|disp=comma||Similar to disp=s except the two values will be separated by a comma, for situations where the first value is already within parentheses. See the Geography tables on [[Labrador]] for an example.
+
|-
+
|abbr=in||Abbreviates only the input unit.
+
|-
+
|abbr=out||Abbreviates only the output unit.
+
|-
+
|abbr=comma||Abbreviates (removes) commas. This is a limited, temporary option, until comma=off can be implemented. For ranges, using abbr=comma conflicts with internal options, so instead, append "nocomma" to a range-word: tonocomma, bynocomma, andnocomma, -nocomma & xnocomma.
+
|-
+
|abbr=mos||For ranges, abbreviates as in [[WP:MOS]], with the input unit repeated, twice.
+
|}
+
 
+
===Rounding===
+
''Convert'' supports four types of rounding:
+
;Rounding to a given precision
+
:Specify the desired precision with the fourth unnamed parameter or third unnamed parameter in the case where the ''convert to'' parameter is skipped (see above).  The conversion is rounded off to the nearest power of 1/10 this number.  For instance, if the result is 8621 and the round number is '-2', the result will be 8600.  If the result is '234.0283043' and the round number is '0', the result will be 234.
+
 
+
;Rounding to a given number of significant figures
+
:Specify the desired number of significant figures using <code><nowiki>|sigfig={some non-negative integer}</nowiki></code> as noted above.
+
 
+
;Combine both of the above
+
:If both the desired precision and the desired number of significant figures are specified, the conversion will be rounded to the least precise of these.
+
 
+
;Default rounding
+
:If neither the desired precision nor the desired number of significant figures are specified, the conversion will be rounded either to a comparable precision as the input value (the number of digits after the decimal point—or the negative of the number of non-significant zeroes before the point—is increased by one if the conversion is a multiplication by a number between 0.02 and 0.2, remains the same if the factor is between 0.2 and 2, is decreased by 1 if it is between 2 and 20, and so on) or to two significant figures, whichever is the most precise.  An exception to this is temperature wherein the conversion will be rounded either to precision comparable to that of the input value or to that which would give three significant figures when expressed in kelvins, whichever is the most precise.
+
 
+
=== Units supported ===
+
 
+
{{selfref|See also: [[Template:Convert/list of units|Convert/list of units]]}}
+
The table below lists units supported by this template. It is divided up according to the quantity being measured. Not all supported units are listed here; there are links to complete lists for each quantity.
+
 
+
The codes listed in the ''code'' column (column 3) are accepted as input by the template.
+
These can be used as the second or third unnamed parameter. For some units there exist alternative codes. These are listed in brackets and have been incorporated to make the code more flexible for editors, e.g. °F ''or'' F may be entered.
+
 
+
The codes listed in the ''combinations'' column (column 7) can be used to produce multiple conversions. They can only be used as the third unnamed parameter, e.g. <code><nowiki>{{convert|55|nmi|km mi}}</nowiki></code> produces "{{convert|55|nmi|km mi}}".
+
 
+
<div style="height: 400px; overflow: auto; padding: 3px; border: 1px solid #aaa;">
+
{{Convert/list of units}}
+
</div>
+
 
+
===Examples===
+
* Monitor quality or look at examples at {{tl|Convert/check}}.
+
 
+
===See also===
+
* {{tl|convinfobox}} for use in infoboxes
+
* {{tl|bbl to t}} for converting barrel of oil to tonnes
+
* {{tl|CwtQtrLb to kg}} for converting long hundred weights, quarters and pounds into kilograms
+
* {{tl|DMS2Deg}} for converting degrees, minutes and seconds to decimal degrees
+
* {{tl|HMS2Deg}} for converting [[hour angle]]s, given in hours, minutes and seconds, to decimal degrees
+
* {{t1|height}} for converting and displaying a person's height
+
* {{tl|miles-chains}} for converting miles and chains to kilometres linking "chains"
+
* {{tl|pop density}} for converting a population and area to a density
+
* {{tl|Inflation}} for calculating inflated prices
+
* {{tl|metricate}}
+
  
 
<includeonly>
 
<includeonly>
{{pp-template}}
 
 
<!-- ADD CATEGORIES BELOW THIS LINE -->
 
<!-- ADD CATEGORIES BELOW THIS LINE -->
 +
[[Category:SI unit templates|{{PAGENAME}}]]
 
[[Category:Conversion templates| ]]
 
[[Category:Conversion templates| ]]
 
 
<!-- ADD INTERWIKIS BELOW THIS LINE -->
 
<!-- ADD INTERWIKIS BELOW THIS LINE -->
[[es:Plantilla:Convert]]
 
[[bn:template:Convert]]
 
[[fr:Modèle:Conversion]]
 
[[id:Templat:Convert]]
 
[[it:Template:Converti]]
 
[[ja:Template:Convert]]
 
 
[[no:Mal:Convert]]
 
[[no:Mal:Convert]]
[[pt:Predefinição:Convert]]
 
[[th:แม่แบบ:Convert]]
 
 
[[zh:Template:Convert]]
 
[[zh:Template:Convert]]
 +
 
</includeonly>
 
</includeonly>

Latest revision as of 15:44, 11 April 2020


Purpose

To show quantities in a primary and secondary display, such as 32 metres (105 ft), or 18 °C (64.4 °F).

Usage

{{convert|original_value|original_unit|conversion_unit|round_to}}

Examples

Input Displays as
{{convert|32|m|ft|0}} 32 metres (105 ft)
{{convert|18|°C|°F|1}} 18 °C (64.4 °F)
{{convert|10|mi|km|0}} 10 miles (16 km)
{{convert|25|km|mi|0}} 25 kilometres (16 mi)
{{convert|1|lb|kg|0}} 1  (Expression error: Unexpected round operator. )
{{convert|1250|sqft|sqm|1|lk=on}} 1,250 square feet (116.1 )
{{convert|20.5|sqkm|sqmi|1|lk=on|abbr=on}} 20.5 km² (7.9 sq mi)
{{convert|641|acre|sqmi|3|lk=on|abbr=on}} 641 acres (1.002 sq mi)
However
{{convert|641|acre|sqmi|2|lk=on|abbr=on}} 641 acres (1 sq mi) because 640 acres equals one square mile; 641 acres rounded to 2 would equal 1.00 sq mi. Therefore it is displayed as 1 sq mi.

Tricks

In order to...
Use U.S. spelling attach |sp=us
Make units wikilinked attach |lk=on (The manual of style suggests that you only link the first instance).
Use the singular for grammar attach |sing=on (ex: "The 190 foot (58 m) bridge" as opposed to "feet")
Abbreviate all units attach |abbr=on
Use a / instead ( ) attach |disp=slash (or shorthand: |disp=/) (ex: 190 foot/58 m)

Rounding

The number given for rounding rounds off the result to the power of 1/10 the rounding number. For instance, if the result is 8621 and the round number is '-2', the result will be 8600. If the result is '234.0283043' and the round number is '0', the result will be 234.

Conversions

The abbreviations to the right of the units are the abbreviations that can be entered when using the template. Through various revisions of this template, some units have incorporated multiple abbreviations to make the code more flexible for editors, e.g. °F or F may be entered. Though they may not be the correct abbreviations, the correct abbreviation will always be displayed when you use {{convert}}.


Units supported by {{convert}}
system unit abbreviation used in coding
(alternative abbreviations)
abbreviation printed 20px US spelling |sp=us
Area
SI square metre sqm square meter
square kilometre sqkm km² square kilometer
Imperial & U.S. Customary acre acre acre (or acres)
square foot sqft sq ft
square yard sqyd sq yd
square mile sqmi sq mi
square nautical mile sqnmi sq nmi
old metric hectare ha ha
Length
SI millimetre mm mm millimeter
centimetre cm cm centimeter
metre m m meter
kilometre km km kilometer
Imperial & U.S. Customary inch in in
foot ft ft
yard yd yd
mile mi mi
nautical mile nmi nmi
Other astronomical unit AU AU
Speed
SI metres per second m:s (m/s) m/s meter per second
kilometres per hour km:h (km/h or kph) km/h kilometer per hour
Accepted non-SI knot knot kt
Imperial & U.S. Customary feet per second ft:s (ft/s) ft/s
miles per hour mi:h (mph or mi/h) mph
Temperature
SI kelvin K K
degrees Celsius °C (C) °C
Imperial & U.S. Customary degrees Rankine °R (R) °R
degrees Fahrenheit °F (F) °F

Example/monitor page

Monitor quality or look at examples at Template:Convert/check