Template:Convert/doc

Usage
This template shows measurement quantities as primary and converted secondary units (or ranges), with optional rounding, wikilinks, abbreviation, or US spellings, and various separators including: parentheses "", "or", hyphens, comma, "to" or dashes. It can help users by calculating correct conversions from one unit of measurement to another, particularly for more complex units. It's also useful by making the text adhere to the Manual of Style.

Styles include: distance "32 m" and "32 m"; temperature "18 °C"; mass "55.0 kg" or "65 to 80 kg"; etc. For units see: Convert/list of units.


 * Optional parameters, in examples below, allow abbreviated units (abbr=on), or U.S. spellings (sp=us for meter), or hyphenation (adj=on), etc.
 * This template may in some cases directly convert to other base units, for example  will directly convert the km/ to mp, as in 29.8 km/s.
 * For this template many levels of substitution are possible, hence doing this fully, step by step, is cumbersome. Use Special:ExpandTemplates instead.
 * The template provides some dimensional analysis to check for compatible units. The user should be careful that 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 , for example, is for the avoirdupois ounce (a unit of mass), do not use this if you want fluid ounces.  Note also that the code   gives pounds mass, for pounds force use.
 * This documentation page tends to lag behind in terms of what the template can do. For more details, see the talk page and its archives.

Unit name or abbreviation (symbol): 1 pound or 1 lb?

 * on will produce the unit's symbol:
 * &rarr; 1 lb
 * &rarr; 1 lb

Adjective: a 10-mile distance
Use on to produce the adjective form. The difference:
 * &rarr; 10 mi to go. -- Regular
 * &rarr; A 10 mi distance. -- Adjective

Rounding: 123 ft is 40 m or 37 m or 37.5 m?
Convert supports four types of rounding:
 * Rounding to a given precision
 * Specify the desired precision with 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 power of $1/undefined$ 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  as noted above.


 * Default rounding
 * If neither the desired precision nor the desired number of significant figures is specified, the conversion will be rounded either to precision comparable to that of 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 more 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 more precise.

Spelling of units: default UK metre or US meter?
Default spelling of units is en-UK. To show en-US spelling, use us:
 * &rarr; 1 m
 * &rarr; 1 m

Spell out numbers: ten miles
To write a number in words, use in:
 * &rarr; 10 mi

To spell out both in and out values:
 * &rarr; 10 mi

To make first letter a capital, use In, On
 * &rarr; 10 mi
 * &rarr; 10 mi

Parameter list
Examples of number grouping:
 * → 1234 m
 * → 1234 m
 * → 12345 m
 * → 1234 m
 * → 1234 m
 * → 123,456,789 m

Examples of spelling input values:
 * → 10 mi
 * → 10 mi
 * → 1/3 mi

Free text in a range: 12 m but not greater than 14 m
The range-indicator options like – are limited to a list (see above). It might be needed to use &lt;any text> in values to convert, to get a result like:

convert does not have this option. One can use variant templates:
 * &rarr;

For these situations, see the documentation of:
 * convert/2
 * convert/3
 * convert/4

TemplateData
{ "description": "Converts measurements to other units.", "params": { "1": { "label": "value", "description": "the value to convert", "type": "number" }, "2": { "label": "from unit", "description": "", "type": "string/line" }, "3": { "label": "to units", "description": "", "type": "string/line" }, "4": { "label": "precision or suffix", "description": "significant digits after decimal dot or, if negative, exponent of ten", "type": "number" }, "lk": { "label": "link units", "description": "“on” all, “in” input, “out” output or “off” no units", "default": "off", "type": "string/line" }, "abbr": { "label": "abbreviation", "description": "show “on” unit symbols, “off” all unit names in full words, “in” abbreviated input units, “out” abbreviated output units or “values” no unit names", "type": "string/line" }, "sp": { "label": "spelling", "description": "“us” US", "type": "string/line" }, "adj": { "label": "adjective", "description": "adjective form (singular unit name appended by hyphen) “on” or “mid” to put conversion at end", "type": "string/line" }, "disp": { "label": "conversion", "description": "show conversion … “or” after ‘or’, “b” in parentheses, “x” with custom prefix and suffix, “table”/“tablecen”, “output only” alone, “output number only” alone and without unit, “flip” first, “unit” not at all but input unit; if the value is a number it is used as precision", "default": "b", "type": "string/line" }, "sigfig": { "label": "significant figures", "description": "number that sets the number of significant figures", "type": "number" }, "sortable": { "label": "sort key", "description": "“on” generate a hidden sort key", "type": "string/line" } }}