Help:Convert/parameter options

This page wants to give an elaborate overview of the } parameters and their options. It is a technical overview.
 * Help:Convert units • Simplified list of some commonly used units.
 * Help:Convert messages • Error and warning messages.

Units

 * Help:Convert units • Simplified list of some commonly used units
 * Module:Convert/documentation/conversion data/doc • Full list of units

Rounding
By default, the output value is rounded to adjust its precision to match that of the input. An input such as 1234 is interpreted as 1234 ± 0.5, while 1200 is interpreted as 1200 ± 50, and the output value is displayed accordingly, taking into account the scale factor used in the conversion.

If the default is not wanted, the precision of output values can be specified using:
 * (where  is a number) to specify the number of digits to be displayed after the decimal mark (round output to N decimal places)
 * (where  is a negative number) to specify the number of digits before the decimal mark that should be replaced with zero (round output to nearest 10N).
 * (where  is a positive number) to specify the number of significant digits (round output to N significant figures)
 * to round the output to the nearest multiple of 5

Examples:
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1234 ft
 * → 1230 ft
 * → 1230 ft
 * → 1230 ft
 * → 5670 sqft
 * → 5670 sqft

Spell
Use us to specify that unit names should be displayed with US spelling:
 * Use US (en-US) spelling for unit names
 * → 6 km
 * → 6 km

Use in to specify that the input value should be spelled in words, or In (uppercase " ") to start with an uppercase letter:
 * Spell out numbers in words
 * → 5 mi
 * → 5 mi
 * → 5 mi
 * → 5 mi
 * → 2+1/4 mi
 * → 2+1/4 mi

The input and output can be "flipped", as shown in these examples. Logically, the resulting first number is spelled: The " " provides an empty output unit to mean "use the default".
 * → 5 mi
 * → 5 mi

Both input and output values can be spelled:
 * → 5 mi
 * → 5 mi

Fractions
An input value can be specified as a fraction.
 * → 1/2 in
 * → 1/2 in
 * → 2+1/2 in
 * → -2-1/4 in
 * → 1/2 in

If two slashes are used, a horizontal fraction bar is used.
 * → 1//2 in
 * → 2+1//2 in

An output can be expressed with a fraction using  where N is the denominator. For example,  rounds the output to the nearest eighth.
 * → 219 mm
 * → 219 mm
 * → 219 mm
 * → 219 mm
 * → 222 mm

A fraction is applied to the output unit (if there is only one), or to non-SI units (if using a combination), except that if a precision is also specified, the fraction only applies to the hand unit.
 * → 18.45 in
 * → 18.45 in
 * → 18.45 in

Joins
The disp ("display") option may be used to "join" the input and output, as shown in the following examples.

Ranges
The following ranges provide different output when units are abbreviated.

Ranges can use more than two values.

Ranges can be specified in the first parameter.

Extra words
Some options provide text that is included in the output, as shown in the following examples.

In each of the above examples, " " provides an empty output unit which causes the default output to be used. An output unit, possibly empty, must be specified to avoid the template interpreting the extra text as the output unit. For example, using  has the same effect as using , namely that an error would occur because " " would be used as the output unit. The following illustrates the error (hover the mouse over the error text to see that the problem is due to " " ) and how it may be avoided.
 * → 4 ft
 * → 4 ft
 * → 4 ft
 * → 4 ft

Displaying parts of a convert
The following examples show how to display only some part of the output result.

Wrapping and line breaking
Convert uses the regular space (" ") and non-breaking space ( which shows: " ") to control line-breaking (also called wrapping/nowrapping).

Wrapping is possible where a space (" ") is used. Prevent wrapping is enforced by using the non-breaking space, that ties and keeps text elements together.
 * may break after "3"
 * , or 3 ft, will not break after "3"

In the examples below, an  is shown as "" (red underscore): " ".

A line break forces a newline (line break), and so overrules any nowrap setting at that point.

The separator between the value and the unit can be a space or a nonbreaking space :
 * Within a measurement (value+unit)
 * When a unit is abbreviated (symbol is shown), the separator is.
 * → 12 m


 * When a unit is not abbreviated (name is shown), the separator is a space.
 * → 12 m
 * This can be set (overruled) to be  by j (for 'join').
 * → 12 m


 * Some units do not have a symbol and always use a space (such as acre).
 * → 3 acre


 * Except, option  ("join") forces the separator to be.
 * → 3 acre


 * Except,  is always used when a measurement is in multiple units.
 * → 1 ft
 * → 2 m


 * Except, if option  is used and the unit is not abbreviated, the separator is a hyphen ("-").
 * → 2 m


 * When the name of a number is used,  is used as the separator between the value and the name. For example, a measurement spelled as "12 million metres" has   before "million" and a space afterwards.
 * → 12 e6m


 * Between measurements
 * A space is used as the separator in a join between the first and second measurement.
 * → 3 ft


 * Except for the special case before "["&thinsp;:
 * → 12 in ( before "[")


 * Multiple output measurements (by listing units) always use a space between measurements ("; " has a space after ";").
 * → 2 acre


 * Between components of a measurement (e.g., in a range; between foot–inch)
 * A measurement in multiple units always uses a space between components ("1 foot 6 inches" has  before the unit names, but a space after "foot").
 * → 1 ft


 * In a range, spaces are generally used to separate items. For example, "to" and "or" have a space before and after in the following.
 * → 12 to 20 in
 * → 12 or


 * The ranges  and   always use  :
 * → 12 +/-
 * → 12 ,


 * The "to(-)" range is an exception. When a unit is not abbreviated, "to" has  before and a space after.
 * → 12 to(-)


 * The "x" range is an exception. When a unit is abbreviated, "×" has a space before and  after.
 * → 12 x


 * Overrule by setting a line break
 * Parameter br adds a forced line break between measurements; brackets are omitted.
 * → 12 m

To see the wikicode result of the convert template: put your  code into Special:ExpandTemplates and then preview by clicking.
 * Preview wikicode

Tables
The following parameters are intended for use in tables.

The following shows the wikitext output by some example converts.

Fixed table
This wikitext:

produces this table:

Sortable table
This wikitext:

produces this table:

Parameter list
Examples of number grouping:
 * → 1234 m
 * → 1234 m
 * → 12345 m
 * → 1234 m
 * → 1234 m
 * → 1,234,567 m
 * → 1,234,567 m

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

Differences from templates previously used
Before December 2013, convert was implemented by a series of templates, not a module. Following are some differences between the new and old convert implementations.
 * Using  works with the module.
 * The module checks unit types and displays an error message if a mismatch occurs.
 * Ranges and all options, including, should work with all units.
 * Scaled units like  are not predefined. With some exceptions, all units accept prefixes e3, e6, e9, e12, e15.
 * The module uses an empty unit code rather than  to mean "use the default unit", as in   (it is also possible to use , but that sets the output precision to zero).
 * The functionality of  and   is handled by the module, except that the module does not support arbitrary text to separate items in a range. Furthermore, the predefined separator words such as "by" and "to" behave in exactly the same manner as they do for standard converts, so a conversion like   would need to use the new   separator rather than   to produce exactly the same output with the module.
 * The module does not have a problem with template loops, and will allow pointless conversions like.

Limitations
This is a list of features that the module may be expected to support, but which will not work.

Composite units cannot be used in a range:
 * → 2 ft

If an expression is wanted, it has to use :
 * → 3*12 ft
 * → undefined ft