289
edits
Changes
no edit summary
=== Usage ===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: parentheses, slash, "or", hyphens, comma, "to" or dashes. Styles include: distance "{{documentation subpageconvert|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= Units of measurement usage on Wikivoyage }}" or "{{convert|65|to|80|kg|lb|abbr=on}}"; etc. For units see: [[Template:Convert/list of units|Convert/list of units]].{||- bgcolor="#FAFEFF" valign=topFormat |Options include: ||[[#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 conventions used for units can be found at [[Wikivoyage:Measurements#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>
=== Convert template usage Examples=======Single value===='''Template {{tl|convert}}class="wikitable"|''' Input''calculates'||' measurements from one unit (you can enter) to another one, and then ''presents the resultsDisplays as'''. For example::<code>|-|<nowiki>{{convert|23.21|kmkg|milb}}</nowiki></code> → ||{{convert|23.21|kmkg|milb}}:<code>|-|<nowiki>{{convert|73.21|mikg|kmlb|0}}</nowiki>||{{convert|3.21|kg|lb|0}}|-|</codenowiki> → {{convert|710|mikg |kmlb |disp=or}}<br /nowiki> Multiple '''formatting''' and calculation options are listed below. ==Unit name or symbol (abbreviation): ''1 pound'' or ''1 ||{{convert|10|kg |lb''?=|disp=or}}By default, the first value shows unit name, the second the symbols (= abbreviation).|-Use |<nowiki>{{paraconvert|abbr6|onft|5|in|m}}</offnowiki>||{{convert|6|ft|5|in|m}} to change this behaviour::<code>!--This is currently broken, see talk page|-|<nowiki>{{lb to kgconvert|12|m|ftin}}</nowiki></code> → ||{{convert|12|lbm|kgftin}} (To compare; default: first value shows unit name):<code-->|-|<nowiki>{{lb to kgconvert|110|abbr=onmi}}</nowiki></code> → ||{{lb to kgconvert|110|abbr=onmi}}:<code>|-|<nowiki>{{convert|1100|lb|kg|abbr=offmpgus}}</nowiki>||{{convert|100|mpgus}}|-|</codenowiki> → {{convert|1120|lbkm/h}}</nowiki>|kg|abbr=off{{convert|120|km/h}}* |-|<nowiki>{{paraconvert|abbr18|in°C|°F}} toggles the default behaviour (</nowiki>||{{paraconvert|abbr18|out°C|°F}})::<code>|-| <nowiki>{{convert|11250|lbsqft|kgm2|abbrlk=in|sigfig=2}}</nowiki></code> → ||{{convert|11250|lbsqft|kgm2|abbrlk=in|sigfig=2}} ==Adjective: ''a 10-mile distance'<br/>Note 'lk==Use {{para|adj|on}} to produce in' links only the adjective forminput unit. The differenceThis example is for illustration only, common units of measurement should not be linked. See:[[Wikipedia:<code>Only make links that are relevant to the context|wp:overlink]].|- |<nowiki>{{convert|1020.5|mim3|kmcuyd|lk=out|abbr=on}} to go</nowiki></code> → ||{{convert|1020.5|mim3|kmcuyd|1|lk=out|abbr=on}} to go. <br/>Note 'lk=out'(To comparelinks only the output unit, default)''[[cu yd]].:<code>|-|<nowiki>A {{convert|10641|miacre|kmkm2 sqmi|adjlk=on}} distance</nowiki></code> → A ||{{convert|10641|miacre|kmkm2 sqmi|adjlk=on}} distance. '<br/>Note '(Adjective form)'' lk==Rounding: on''100 ft'' is ''30 m'' or ''30links all units.5 m'' or ''30Per guidelines, common units should not be linked. See: [[Wikipedia:Only make links that are relevant to the context|wp:overlink]].48 m''?==In detail, it is |-|<nowiki>{{convert|100641|ftacre|mmkm2 sqmi|sigfig=52|disp=lk=on}}. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. </nowiki>||{{convert|641|acre|km2 sqmi|2|lk===Default rounding===:By default, the conversion result will be on}}<br/> Although 640 acres equals 1 square mile; 641 acres rounded either to precision comparable to that of the input value (the number of digits after the two 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 0places equals 1.02 and 000 sq mi.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 more precise. An exception to this is ''rounding temperatures'' (see [[#Rounding temperatures|below]]).}
====Range of values====
:''Note: not yet operational for all units''
{| class="wikitable"
|'''Input'''||'''Displays as'''
|-
|-
|'''Input'''<nowiki>{{convert|60|'''Displays as'''to|170|'''Note'''kg|lb}}</nowiki>||{{convert|60|to|170|kg|lb}}
|-
|<nowiki>{{convert|12360|ftto(-)|m170|-1kg|lb}}</nowiki>||{{convert|12360|ftto(-)|m170|-1kg|lb}} ||
|-
|<nowiki>{{convert|12360|ft-|m170|0kg|lb}}</nowiki>||{{convert|12360|ft-|m170|0kg|lb}} ||
|-
|<nowiki>{{convert|12341|ftto|m50|1F|C}}</nowiki>||{{convert|12341|ftto|m50|1F|C}} ||
|-
|<nowiki>{{convert|55041|ft-|m50 |0F|K}}</nowiki>||{{convert|55041|ft-|m50 |0F|K}} || Approximate value is 167.64 m
|-
|<nowiki>{{convert|55060|ftby|120|m|ft}}</nowiki>||{{convert|55060|ftby|120|m|ft}} || Rounds to 170, when approximate value is 167.64 m
|-
|<nowiki>{{convert|50060|ftx|120|m|0ft}}</nowiki>||{{convert|50060|ftx|120|m|0ft}} || Approximate value is 152.4 m
|-
|<nowiki>{{convert|50060|ft+/-|10|m|ft}}</nowiki>||{{convert|50060|ft+/-|10|m|ft}} |-|<nowiki>{{convert|19| Rounds to 150, when approximate value is 152.|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 m|-|9|L|USgal|abbr=none}}</nowiki>||{{convert|4|-|9|L|USgal|abbr=none}}
|}<!--NOTE: rows require "nowiki", using {{ disappears. -->
===Parameters===
{| class="wikitable"
|-
|-
| {{anchor|sp_us}}Use [[United States|US]] spelling || attach <code><nowiki>{{convert|2|cuyd|m3|abbrsp=values}}us</nowiki></code> || {{convert|2|cuyd|m3|abbr=values}} || Input and output numbers
|-
| {{anchor|lk_in}}Make units [[Wikipedia:Manual of Style (links)|wikilinked]] || attach <code><nowiki>{{convert|2|cuyd|m3|displk=unit}}on</nowiki></code> || to link all units{{convertin5|2|cuyd|m3|disp=unit31}} (default: <tt>lk=off</tt>)<br> attach <code><nowiki>|lk=in</nowiki></code> to link only the input units<br> attach <code><nowiki>|lk=out</nowiki></code> to link only the output units<br>(The [[Wikipedia:Only make links that are relevant to the context| Input unitmanual of style]] suggests that you should not link common units of measurement).
|-
| {{anchor|adj_on}}Use the adjective form || attach <code><nowiki>{{convert|2|cuyd|m3|disp=unit|adj=on}}</nowiki></code> || {{convert|2|cuyd|m3|disp=(e.g. "The 190-foot (58 m) bridge" as opposed to "The 190 feet..."). This produces the adjective form—the unitname in the singular with a hyphen (according to the [[WP:HYPHEN|adj=on}} || Input unit, adjective (hyphenatedManual of Style]]).
|-
| {{anchor|abbr_on}}Abbreviate units, or none || attach <code><nowiki>|abbr=on</nowiki></code>{{convertin5|2|cuyd|cuyd|07}}to show unit symbols{{in5|disp10}}(default: <tt>abbr=outoff</tt>)<br> attach <code><nowiki>|abbr=off}}none</nowiki></code> to show all units in full words<br> attach <code><nowiki> || abbr=in</nowiki></code> {{convert|2|cuyd|cuyd|0|disp=outin5}} to abbreviate input units<br> attach <code><nowiki>|abbr=offout</nowiki></code>{{in5}} || Input (''workaround'')to abbreviate output units.
|-
| Change display option from "( )" || attach <code>|disp=comma<nowiki/code>{{convert|2in5|cuyd|m3|disp=unit24}}to put comma, not parentheses</nowikibr>attach <code>|disp=or</code> || {{convert|2in5|cuyd|m3|disp=unit210}} to put "or" between units<br> attach <code>|disp=s</code> (or <code><nowiki>|| Output unit disp=/</nowiki></code>) for slash (symbole.g. 190 foot/58 metre). The default value is: disp=b for parentheses.
|-
| Display output only || attach <code>|disp=output only<nowiki/code>{{convertin5|2|cuyd|m3|disp=unit2|abbr=off15}}to show result number & unit</nowikibr>attach <code>|disp=output number only</code> || {{convert|2|cuyd|m3in5|3}}to show just number<br>Note when using "disp=unit2|output only" then the unit name can still be shown as full words by abbr=off}} || Output unit (name)none, or linked by lk=on.
|-
| Display unit name (only) || attach <code>|disp=unit<nowiki/code>{{convertin5|2|cuyd|m3|disp=number7}}to show the unit name for a symbol</nowikibr>The unit name will be plural when the amount is not 1, or hyphenated when adj=on. So, </codenowiki> || {{convert|2|cuyd|m3|disp=numberunit}} || Output value</nowiki> shows "cubic yards" plural.
|-
| {{anchor|disp_table}}Display amounts as table cells || attach <tt>|disp=table</tt> (or <tt>|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>{{convert|2abbr=on</nowiki></code>, <code><nowiki>|cuydlk=on</nowiki></code>, <code><nowiki>|m3|displk=out}}in</nowiki></code> or <code><nowiki> || {{convert|2|cuyd|m3|displk=out}} |</nowiki></code>. Example: [[Phnom_Penh#Highways_in_Phnom_Penh| Output value and unithere]]
|-
| Round to a specified number of significant figures|| attach <code><nowiki>{{convert|2|cuyd|m3|dispsigfig=out|abbr=off}{some non-negative integer}</nowiki></code> || {{convert|2|cuyd|m3|disp=ou|abbr=offt}} || Output value and unit|} ==Table options==For . In the wikitable structure, there are two options: split over columns and make case of temperatures Celsius or Fahrenheit this refers to the table sortabledifference with the absolute-zero temperature.===Show numbers only in columns in a table===Using {convert} in a table cellFor example, with {{para|disp|table}} splits the result over at room temperature two columns::<code><nowiki>{{convert|10|m|ft|disp=table}}</nowiki></code> → {{convert|10|m|ft|disp=table}} {{para|disp|tablecen}} does the same, and also centers the text::<code><nowiki>{{convert|20|m|ft|disp=tablecen}}</nowiki></code> → {{convert|20|m|ft|disp=tablecen}} The units are added as a column header::{| class=wikitable! style="width:10em;" | ! style="width:10em;" | m! style="width:10em;" | ftsignificant digits means rounded to tens of degrees.
|-
| Let ''Convert'' decide the unit to convert to|| skip the ''convert to'' parameter (which would otherwise be third unnamed parameter) e.g. <code><nowiki>{{paraconvert|disp100|tablemi|0}}| </nowiki></code> gives ''{{convert|10|m100|ftmi|disp=table0}}''.
|-
|Display input value as a fraction<br/>(still in prototype stage: limited functionality)|| <nowiki>{{paraconvert|disp3/8|tablecenin|mm|3|abbr=on}}</nowiki><font color=blue>'''→'''</font> {{convert| 3/8|in|mm|3|abbr=on}} or <nowiki>{{convert|2011+1/4|in|cm|2|abbr=on}}</nowiki><font color=blue>'''→'''</font>{{convert|11+1/4|in|mcm|ft2|dispabbr=tablecenon}}
|-
|{{paraanchor|disp|<other>sortable_on}} Generate a [[Help:Sorting#Sorting with hidden sortkey|hidden sort key]] for use with a [[Help:Sorting|sortable table]]|| attach <smallcode><nowiki>|sortable=on</nowiki></code> to generate a [[Help:Sorting#Sorting with hidden sortkey|hidden sort key]] (default)in the form of <code><nowiki><span style="display:none">00000005</smallspan></nowiki></code>) so that [[Help:Sorting|{{convert|30|msortable 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|disp=}}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.
|}
===Sorting=Parameters still under construction==:Use both {{para|disp|table}} {{para|sortable|on}} to produce table columns (pipe symbols), with sortable table column. As of January 2013, only the first (lefthand) column will sort (improvements pending). :<nowiki>{{convert|10|m|ft|disp=table|sortable=on}}</nowiki> →<code>{{nowrap|{{convert|10|m|ft|disp=table|sortable=on}}}}</code>:This shows the hidden numerical sortkey:<code>alignclass="rightwikitable"|<span style-! colspan="display:none2">7001100000000000000</span>10 |align="right"|33</code> :{| class="wikitable sortable"! m! ftParameters still under construction. May not work in all situations
|-
| {{convertdisp=tablecen|15+3/4|m|ft|Similar to disp=table|sortable=on}}except that the values with be centered within the column. See the tables at [[La Nouvelle branch]] for in use examples.
|-
| {{convertdisp=comma|15.5|m|ft|Similar to disp=table|sortable=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.
|-
| {{convertabbr=in|16|Abbreviates only the input unit.0|m|ft|disp=table|sortable=on}}
|-
| {{convertabbr=out|16|mAbbreviates only the output unit.|ft-|dispabbr=tablecomma|sortable|Abbreviates (removes) commas. This is a limited, temporary option, until comma=on}}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.
|}
==Parameter list=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 === {convert{selfref|See also: [[Template:Convert/doclist 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/listof 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>
{{pp-template}}<!-- ADD CATEGORIES BELOW THIS LINE -->[[Category:Formatting and function templatesConversion templates| ]] <!-- 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]][[pt:Predefinição:Convert]][[th:แม่แบบ:Convert]][[zh:Template:Convert]]
</includeonly>