Template:Convert/doc

From Wikimedia Commons, the free media repository
Jump to: navigation, search


This is now the Lua version from Module:Convert.

Purpose[edit]

To show measurement quantities as primary and converted secondary units, with optional abbreviation or slash, such as distance "32 metres (105 ft)" or temperature "18 °C (64 °F)" or "18 °C / 64 °F" with optional U.S. spellings or hyphenation.

Cross-posted by request from the English Wikipedia.

Usage[edit]

{{convert|original_value|original_unit|conversion_unit|round_to|...}}
Note
Numbers may be entered with commas—any such commas are removed. 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 U.S. spellings (sp=us for "meter"), or slash separation (disp=slash), or hyphenation (adj=on), etc.

Examples[edit]

Input Displays as
{{convert|5959|m|ft|0}} 5,959 metres (19,551 ft)
{{convert|3.21|kg|lb}} 3.21 kilograms (7.1 lb)
{{convert|3.21|kg|lb|0}} 3.21 kilograms (7 lb)
{{convert|0|kg|lb}} 0 kilograms (0 lb)
{{convert|6|ft|5|in|m}} 6 feet 5 inches (1.96 m)
{{convert|2|m|ftin}} 2 metres (6 ft 7 in)
{{convert|18|°C|°F|sigfig=2}} 18 °C (64 °F)
{{convert|1250|sqft|sqm|lk=on}} 1,250 square feet (116 m2)
{{convert|20.5|sqkm|sqmi|1|lk=on|abbr=on}} 20.5 km2 (7.9 sq mi)
{{convert|641|acre|sqmi sqkm|3|lk=on|abbr=on}} 641 acres (1.002 sq mi; 2.594 km2)
{{convert|641|acre|sqmi sqkm|2|lk=on|abbr=on}} 641 acres (1.00 sq mi; 2.59 km2) because 640 acres equals one square mile; 641 acres rounded to two decimal places would equal 1.00 sq mi.

Tricks[edit]

In order to...
Use U.S. 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 only link the first instance).
Use the singular for grammar attach |adj=on (e.g. "The 190-foot (58 m) bridge" as opposed to "feet"). Note that this also adds hyphenation (as specified by the manual of style).
Abbreviate all units attach |abbr=on
Use a / instead of ( ) attach |disp=slash (or shorthand: |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}
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 100 miles (161 km).

Rounding[edit]

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 a comparable precision as the input value or to a comparable precision to that which would give three significant figures when expressed in kelvin whichever is the most precise.

Units supported by {{Convert}}[edit]

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 55 nautical miles (102 km; 63 mi).

Example/monitor page[edit]

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

Error tracking categories[edit]

Pages and categories where Convert is used with invalid units or options are added to Category:Convert invalid units or Category:Convert invalid options respectively.