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. 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. Single value:  value in_unit 

Range of 2 values, or set of 3 or 4 (see below for list of range options):  {&#123;convert|val1|range|val2 |in_unit|out_unit|round_to|...}} {&#123;convert/3 |val1|range|val2|words|val3|in_unit|out_unit|round_to|...}} {&#123;convert/4 |val1|words|val2|words|val3|words|val4|in_unit|out_unit|...}}
 * Numbers must be entered in unformatted form (without commas). 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 9,000,500 (becomes 9000500).
 * Optional parameters, in examples below, allow abbreviated units (abbr=on), or U.S. spellings (sp=us for meter), 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 very limited in-built capacity for dimensional analysis. It is therefore up to the user to ensure that most 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.
 * 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.

Range of 2 values

 * Note: not yet operational for all units

The following conversions are currently not available as a range of values:
 * Some imperial and US gallon-based units
 * Other fuel-consumption units, except "mpg" or "L100km" shown above.
 * Large scale units (e3, e6, e9)
 * Combination-based units (ft&in, st&lb, lb&oz) due to complexity of the conversion.

Range/set of 3 or 4 values

 * Note: not yet operational for all units

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 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 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.

Supporting modules
The following Lua modules are called by this template:
 * Module:Convert – code to convert units
 * Module:Convert/data – unit definitions
 * Module:Convert/text – text messages, and parameter names and values
 * Module:Convert/extra – extra (temporary) unit definitions; used if a unit is not found in Module:Convert/data
 * Module:ConvertNumeric – code to spell an input value in words

Module:Convert/data is transcluded into every page using the convert module, so experimenting with a new unit in that module would involve a significant strain on the job queue. The Module:Convert/extra module is an alternative which is only transcluded on pages with a unit that is not defined in the main data module.

Help pages
The following help pages are available:
 * Help:Convert (on the English Wikipedia) – overview
 * Help:Convert messages – describes error and warning messages
 * Help:Convert units (on the English Wikipedia) – overview of units

Error reports
A page containing a convert error is added to one of the following categories, providing the page is in a specified namespace (articles and templates, by default):
 * Category:Convert invalid units
 * Category:Convert invalid options

Related pages

 * Convinfobox for use in infoboxes
 * Bbl to t for converting barrel of oil to tonnes
 * Decdeg for converting degrees, minutes and seconds to decimal degrees
 * HMS2Deg for converting hour angles, given in hours, minutes and seconds, to decimal degrees
 * Pop density for converting a population and area to a density
 * Inflation for calculating inflation of Consumer Price Index related prices
 * Metricate
 * RailGauge for converting rail (track) gauges