Template:Convert/doc

From The Sonic Eats Rings Museum
Jump to navigation Jump to search
This is a documentation subpage for Template:Convert (see that page for the template itself).
It contains usage information, categories and other content that is not part of the original template page.

Note

{{Convert}} no longer accepts kt as code for the knot. The code kt will be reassigned for the kilotonne. Please use kn instead. Sorry for any inconvenience.

The codes sqm and sqkm have also been removed. Use m2 and km2.

Purpose

To show measurement quantities as primary and converted secondary units, with optional abbreviation or slash, such as distance "Template:Convert/m" or temperature "Template:Convert/°C" or "Template:Convert/°C" with optional US spellings or hyphenation.

Usage

Single value:

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

Range of values:

{{convert|orig_val1|range|orig_val2|original_unit|conversion_unit|round_to|...}}
Notes
  • 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.
  • 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.
  • For this template many levels of 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 {{bbl to t}}). Also beware of units with similar names; the code oz, for example, is for the avoirdupois ounce (a unit of mass), do not use this if you want fluid ounces.
  • 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

Single value:

Input Displays as
{{convert|3.21|kg|lb}} Template:Convert/LoffAoffDbSoff
{{convert|3.21|kg|lb|0}} Template:Convert/LoffAoffDbSoff
{{convert|0|kg|lb}} Template:Convert/LoffAoffDbSoff
{{convert|6|ft|5|in|m}} Template:Convert/and/in
{{convert|18|°C|°F}} Template:Convert/°C
{{convert|1250|sqft|m2|lk=in|sigfig=2}} Template:Convert/sqft
See that 'lk=in' applies link to input unit only. This example is for illustration only, common units of measurement should not be linked. See: wp:overlink.
{{convert|20.5|km2|sqmi|lk=out|abbr=on}} Template:Convert/LoutAonDbSoff
See that 'lk=out' applies link to output unit only. This example is for illustration only, common units of measurement should not be linked. See: wp:overlink.
{{convert|641|acre|km2 sqmi|lk=on}} 641 acres (Template:Convert/multi2LonAonSoff)
See that 'lk=on' applies links to input and output units. This example is for illustration only, common units of measurement should not be linked. See: wp:overlink.
{{convert|641|acre|km2 sqmi|2|lk=on}} 641 acres (Template:Convert/multi2LonAonSoff)
Note that because 640 acres equals one square mile; 641 acres rounded to two decimal places equals 1.00 sq mi.

Range of values (not yet operational for all units):

Input Displays as
{{convert|60|and|170|kg|lb}} Template:Convert/Dual/LoffAoffDbSoff
{{convert|60|to|170|kg|lb}} Template:Convert/to
{{convert|60|to(-)|170|kg|lb}} Template:Convert/to(-)
{{convert|60|-|170|kg|lb}} Template:Convert/Dual/LoffAoffDbSoff
{{convert|60|by|120|m|ft}} Template:Convert/m
{{convert|60|x|120|m|ft}} Template:Convert/m
{{convert|60|+/-|10|m|ft}} Template:Convert/m

The following range conversions are currently not available:

  • Temperature-based units (°C to °F, etc.) due to complexity of the conversion
  • Imperial and US gallon-based units
  • Fuel consumption units (mpg, L/100km)
  • Large scale units (e3, e6, e9)
  • Combination-based units (ft&in, st&lb, lb&oz) due to complexity of the conversion

Parameters

Use US spelling attach |sp=us
Make units wikilinked attach |lk=on to link all units
attach |lk=in to link only the input units
attach |lk=out to link only the output units
(The manual of style suggests that you should not link common units of measurement).
Use the adjective form attach |adj=on (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 Manual of Style).
Abbreviate all units attach |abbr=on
Use a / instead of ( ) attach |disp=s (or |disp=/) (e.g. 190 foot/58 metre). Note that when using slashes all unit names either spelt out in full or abbreviated (where there exists an abbreviation).
Use in a table attach |disp=table 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 |abbr=on, |lk=on, |lk=in or |lk=out. Example: here
Round to a specified number of significant figures attach |sigfig={some non-negative integer}. 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.
Let Convert decide the unit to convert to skip the convert to parameter (which would otherwise be third unnamed parameter) e.g. {{convert|100|mi|0}} gives Template:Convert/mi.
Display input value as a fraction {{convert|3/8|in|mm|3|abbr=on}} Template:Convert/LoffAonDbSoff or {{convert|11+1/4|in|cm|2|abbr=on}}Template:Convert/LoffAonDbSoff

Parameters still under construction

Parameters still under construction. May not work in all situations
disp=or Similar to disp=s except the word "or" will be placed between the values. Does not currently work with multiple conversions (e.g. Liters to U.S. and imperial gallons) ({{convert|20|mi|km|disp=or}})--->(Template:Convert/mi)
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.

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 |sigfig={some non-negative integer} 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 decimals remains the same if the conversion is a multiplication by a number between 0.2 and 2, is decreased by 1 if the factor is between 2 and 20, etc.) 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 kelvin, whichever is the most precise.

Units supported

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. {{convert|55|nmi|km mi}} produces Template:Convert/nmi.

Without box: Template:Convert/list of units.

Template:Convert/tsuboTemplate:Convert/list of units/volume/short listTemplate:Convert/list of units/speed/short listTemplate:Convert/list of units/force/short listTemplate:Convert/list of units/energy/short listTemplate:Convert/list of units/temperature/short listTemplate:Convert/list of units/mass/short listTemplate:Convert/list of units/extra
Abridged list of units supported by {{Convert}}

Template:Convert/list of units/explanation Template:Convert/list of units/length/short list

Area
(Full list)
system unit code
(alternative)
abbreviation notes conversion factor/m² combinations
SI

Template:Convert/list of units/rowtop

  • km2 sqmi

Template:Convert/m2

  • m2 sqft
square centimetre cm2 cm² US spelling: square centimeter
0.0001
  • cm2 sqin

Template:Convert/mm2

  • mm2 sqin
non-SI metric

Template:Convert/list of units/rowtop

Imperial
&
US customary

Template:Convert/sqmi

  • sqmi km2

Template:Convert/list of units/rowNa Template:Convert/sqyd Template:Convert/sqft

  • sqft m2 (sqfoot m2)

Template:Convert/sqin

  • sqin cm2
Other

Template:Convert/sqnmi Template:Convert/list of units/rowNa

Example/monitor page

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

See also

  • {{Inflation}} template for calculating inflated prices in USA, UK and other countries.
  • {{Height}} template for calculating (body) height with precision.