Template:Convert/doc

Units of measurement usage on Wikivoyage
Format and conventions used for units can be found at Measurements.

To ensure units are displayed correctly, the simplified individual template should be used.

The Convert template can be used in cases where standard format is not optimum.

Simplified unit of measurement templates

 * km, mi
 * m, ft, yd
 * mm, in
 * ha, acre
 * km2, mi2
 * m2, ft2
 * kmh, mph
 * kg, lb
 * g, oz
 * C, F

Convert template usage
Template convert calculates measurements from one unit (you can enter) to another one, and then presents the results. For example:
 * → 2 km
 * → 7 mi

Multiple formatting and calculation options are listed below.

Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first value shows unit name, the second the symbols (= abbreviation). Use on/off to change this behaviour:
 * → 1 lb (To compare; default: first value shows unit name)
 * → 1 lb
 * → 1 lb


 * in toggles the default behaviour (out):
 * → 1 lb

Adjective: a 10-mile distance
Use on to produce the adjective form. The difference:
 * → 10 mi to go. (To compare, default)
 * → A 10 mi distance. (Adjective form)

Rounding: 100 ft is 30 m or 30.5 m or 30.48 m?
In detail, it is 100 ft. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.

Default rounding

 * By default, the conversion result 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 rounding temperatures (see below).

Convert supports four types of rounding:

Round to a given precision: use 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/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.

Round to a given number of significant figures: use sigfig
To specify the output number to be with n significant figures use &lt;number>: Setting &lt;=0 is meaningless
 * To compare: 1200 ft → 1200 ft
 * 1200 ft → 1200 ft
 * 1200 ft → 1200 ft
 * 1200 ft → 1200 ft
 * 1200 ft → 1200 ft
 * 1200 ft → 1200 ft

Round to a multiple of 5: 15, 20, 25, ...
Using 5 rounds the outcome to a multiple of 5.
 * → 10 m
 * → 10 m

Similar: using 25 rounds the outcome to a multiple of 25.
 * → 10 m
 * → 10 m
 * To compare:  → 10 m

In a range, one can round each value individually to the default. Use each:
 * → 10 x 200 x 3000 m
 * → 10 x 200 x 3000 m

Round to a multiple of a given fraction: 2 3/16 inch
Specify the desired denominator using &lt;some positive integer&gt;. (Denominator is the below-the-slash number, for example the 3 in 1/3).
 * → 5.56 cm
 * → 8 cm

The fraction is reduced when possible:
 * → 8 cm
 * → 8 cm (To compare)

Rounding the temperatures °C, °F and K
In temperatures, 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.
 * → 10 C

Note
 * For a temperature difference, like to convert "A rise of 20 °C", use 20 &tc.
 * → A rise of 20 C-change


 * To compare: "A temperature of 20 °C" would yield: A temperature of 20 C

Into multiple units: 10 C
Separate the multiple output units by a space:
 * → 10 C
 * → 5 km

A range: 6 to 17 kg (13 to 37 lb)
Range indicators are entered as the second parameter (between the values). Range separators can be:

Multiple dimensions: 6 x

 * Use "by":
 * → 6 by


 * Use "×" or ""x"":
 * → 6 x

In science, the formal way is to set  and on (keeping dimensions right, like in area = x km2):
 * → 6 x

About feet, inch in ranges and multiples
While it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
 * → 1 ft (to compare)
 * → 1 ft

Spelling of unit name: UK metre or US meter?
Default spelling of units is the British metre. To show the American spelling, use us:
 * → 1 m -- default
 * → 1 m

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

To make first letter a capital, use In
 * → 10 mi

Extra words: 4 planted acres

 * Incomplete section
 * → 4 acre

Extra adjective words: A 10 ft corridor

 * → 10 ft

Grammatical construction: The 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons

 * "The American defenders had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons."

This formatted result is not possible straightforward by using convert. However, it can be made in three steps.
 * Step 1: Enter the input numbers and units in convert just to get the calculated output:
 * → had 18, cannons
 * The core conversion should look good now. You can save this (or preview).
 * Step 2: We need the resulting text in plain code in the page, not as a ... template.
 * For this, add  to the template name (for 'substitute') :
 * As a check: the preview result should show the conversion correct, with the numbers still right.
 * Now save this.
 * → had 18, 24, 32 pounds (8, 11, 15 kg) cannons
 * Step 3: When opening the edit screen again, you'll see that the text is there in code. The template ... itself has disappeared. You can change the text as needed. The edit screen text is:
 * You can edit this text to add the grammar:
 * After saving your edit, it shows:
 * → "had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons".
 * You can edit this text to add the grammar:
 * After saving your edit, it shows:
 * → "had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons".
 * → "had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons".

Using an SI prefix: gigameter (Gm), or micrometer (μm)
Units can have an SI prefix like  before the unit: , and   before the name:. These are plain multiplication factors.

To illustrate, these are trivial calculations (from meter to meter), showing the multiplication factor:
 * 12 Gm
 * 12 μm

The prefix can be added before the SI unit (here: unit  for meter):
 * → 12 Gm
 * : 12 Mm
 * : 12 km
 * : 12 mm
 * : 12 μm
 * : 12 um (letter "u" can be used for "μ" here)

The prefix can be used in the output unit:
 * → 12000 mi
 * → 12 in

As an exception, the non-SI unit "inch" can have the "μ" prefix too)
 * → 12 μm

Thousands separator: 1,000 mi and 1000 mi
In input, a comma for thousands separator is accepted. A gap (space) is not. In output, by default, the thousand separator is the comma:
 * → 1,234,567 m
 * → 1,234,567 m
 * → 1 234 567 m

Set off to remove the separator:
 * → 1234567 m

Use gaps to set digit grouping by gap in larger numbers (thousands separator):
 * → 1234567 m (To compare, default)
 * → 1234567 m

Setting 5 or gaps5 will only add the separator when the number of digits is 5 or more:
 * → 1234 m (To compare, default)
 * → 1234 m
 * → 1234567 m
 * → 1234 m
 * → 1234567 m

Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by disp.

Options are:  (the default),  ,  ,  ,  ,  :
 * → 10 m --  brackets are the default
 * → 10 m
 * → 10 m
 * → 10 m

Setting br will force a new line


 * → 10 m

Setting x allows any text as separator:


 * → 10 m -- (To display spaces, use )

Flipping (reordering) the two measurements: 1 mi
Setting flip will flip (swap) the two measurements:
 * → 1 mi (To compare, default)
 * → 1 mi

When converting to multiple units, the effect is:
 * → 10 km
 * → 10 km

Displaying parts of the result: 2 cuyd
It is possible to display only parts of the conversion result:

Table options
For the wikitable structure, there are two options: split over columns and make the table sortable.

Show numbers only in columns in a table
Using {convert} in a table cell, with table splits the result over two columns:
 * → 10 m

tablecen does the same, and also centers the text:
 * → 20 m

The units are added as a column header:
 * {| class=wikitable

! style="width:10em;" | ! style="width:10em;" | m ! style="width:10em;" | ft
 * table
 * 10 m
 * tablecen
 * 20 m
 * &lt;other> (default)
 * 30 m
 * }
 * &lt;other> (default)
 * 30 m
 * }

Sorting

 * Use both table on to produce table columns (pipe symbols), with sortable table column. As of January 2013, only the first (lefthand) column will sort (improvements pending).


 * 10 m →


 * This shows the hidden numerical sortkey:


 * {| class="wikitable sortable"

! m ! ft
 * 15+3/4 m
 * 15.5 m
 * 16.0 m
 * 16 m
 * }
 * 16.0 m
 * 16 m
 * }
 * }

TemplateData
{	"description": "Converts measurements to other units.", "params": { "1": {			"label": "Value", "description": "The value to convert.", "type": "number", "required": true },		"2": {			"label": "From unit", "description": "The unit for the provided value.", "type": "string", "example": "km", "required": true, "suggestedvalues": [ "km2", "m2", "cm2", "mm2", "ha", "sqmi", "acre", "sqyd", "sqft", "sqin", "km", "m", "cm", "mm", "mi", "yd", "ft", "in", "kg", "g", "mg", "lb", "oz", "m/s", "km/h", "mph", "K", "C", "F", "m3", "cm3", "mm3", "L", "mL", "cuft", "cuin", "U.S.gal", "U.S.oz", "psi", "mpgU.S.", "$/lb", "$/kg" ]		},		"3": {			"label": "To units", "description": "The units to convert into. Separate units by a space for multiple outputs. In an output unit, use + for a multiplication space.", "type": "string", "example": "mi nmi", "suggested": true, "suggestedvalues": [ "km2", "m2", "cm2", "mm2", "ha", "sqmi", "acre", "sqyd", "sqft", "sqin", "km", "m", "cm", "mm", "mi", "yd", "ft", "in", "kg", "g", "mg", "lb", "oz", "m/s", "km/h", "mph", "K", "C", "F", "m3", "cm3", "mm3", "L", "mL", "cuft", "cuin", "U.S.gal", "U.S.oz", "psi", "mpgU.S.", "$/lb", "$/kg" ]		},		"4": {			"label": "Precision or suffix", "description": "Significant digits after decimal dot or, if negative, exponent of ten.", "type": "number" },		"lk": { "label": "Link units", "description": "Indication of what units to apply wikilinks to. Use “on” for all, “in” for the input unit, “out” for the output units, or “off” for none of the units. For more fine-grained control over which units to link, use the template multiple times.", "default": "off", "type": "string", "example": "on", "suggestedvalues": [ "in", "out", "on", "off" ]		},		"abbr": { "label": "Abbreviation", "description": "Display for the units: “on” to display all units using their unit symbols, “off” to display all units in full words, “in” to display the unit symbol for the input unit, “out” to display the unit symbols for the output units, “unit” to display unit symbols for both input and output units when using scientific notation, “values” for no units at all (neither unit symbols nor full words of units).", "default": "out", "type": "string", "example": "on, unit, in, out, off", "suggested": true, "suggestedvalues": [ "in", "off", "none", "on", "out", "unit", "values", "~"			]		},		"sp": { "label": "Spelling", "description": "Spelling of units. Use “us” to display unit names using U.S. spelling.", "type": "string", "example": "us" },		"adj": { "label": "Adjective", "description": "Whether to use adjectival form. Use “on” for singular unit name appended by a hyphen, “mid” to put conversion at end, or “off” (default) for no adjectival form.", "type": "unbalanced-wikitext", "example": "on", "default": "off", "suggestedvalues": [ "mid", "on", "pre", "ri0", "ri1", "ri2", "ri3", "off" ]		},		"disp": { "label": "Conversion", "description": "Display conversion result: “or”: after ‘or’, “x”: with custom prefix and suffix, “b”: in parentheses, “table”/“tablecen”, “output only”: alone, “output number only”: alone and without unit, “unit”: not at all but input unit; if the value is a number it is used as precision.", "type": "string", "example": "b", "suggestedvalues": [ "b", "sqbr", "br", "comma", "or", "number", "output number only", "out", "output only", "preunit", "table", "tablecen", "unit", "unit2", "x" ]		},		"order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip", "suggestedvalues": [ "flip", "out" ]		},		"sigfig": { "label": "Significant figures", "description": "Indicates the number of significant figures to be used in rounding.", "type": "number" },		"round": { "label": "Rounding output", "description": "The type of rounding. “5” rounds the output number to nearest multiple of 5, “25” to nearest multiple of 25, “each” rounds each number in a range.", "type": "number" },		"comma": { "label": "Thousands separator", "description": "Sets or suppresses the use of thousands separators in the numbers. “off”: no separator; “gaps”: use space instead of comma as thousands separator; “5”: only add thousands separator when the integral part of the number uses 5 positions or more (10,000 or more; if using comma as thousands separator, 1234 would produce '1234', 12345 would produce '12,345').", "default": "on", "type": "boolean", "example": "off" },		"sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "boolean", "example": "on" },		"spell": { "label": "Spell numbers?", "description": "If used, spells input or input and output numbers in words, optionally capitalizing the first", "example": "'in', 'In', 'on', or 'On'", "type": "string", "suggestedvalues": [ "in", "In", "on", "On" ]		},		"sing": { "type": "boolean", "deprecated": "use adj=", "label": "Singular?", "description": "If 'yes', uses singular form of units (deprecated)", "example": "yes" },		"frac": { "label": "Fraction?", "description": "fraction as rounding unit", "type": "number" },		"$": {			"label": "Currency symbol", "description": "sets currency symbol in both units", "example": "$=€ will show \" €10 per mile (€6.2/km)\"", "type": "string" },		"input": { "label": "WD property", "description": "Reads the property value of the item (article), then converts it", "example": "undefined undefined (P2046=area)", "type": "string" },		"altitude_ft": { "label": "Mach altitude (ft)", "description": "Mach (speed) depends on altitide", "type": "number", "suggestedvalues": [ "10000"			]		},		"altitude_m": { "label": "Mach altitude (m)", "description": "Mach (speed) depends on altitude", "type": "number" }	},	"format": "inline", "paramOrder": [ "1",		"2",		"3",		"4",		"lk", "abbr", "sp", "adj", "disp", "order", "sigfig", "round", "comma", "sortable", "spell", "sing", "frac", "$",		"altitude_ft", "altitude_m", "input" ] }