Kigezo:Convert
This template uses Lua: |
Template {{convert}} calculates from one measurement unit to another one, and then presents the results, formatted. The complete list of unit symbols recognized by the template is here.
For example:
{{convert|2|km|mi}}
→ kilometre 2 (mi 1.2) (km entered, converted into miles){{convert|7|mi|km}}
→ mile 7 (km 11) (mi entered, converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ km 2 (mi 1.24){{convert|7|mi|km|2|abbr=on}}
→ mi 7 (km 11.27)
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ kilometre 2 hadi 5 (mi 1.2 hadi 3.1){{convert|2|-|5|km|mi}}
→ kilometre 2–5 (mi 1.2–3.1)
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ km 2–5 (mi 1.24–3.11){{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ kilometre 2 na 5 (mile 1.24 na 3.11)
Units to convert
[hariri chanzo]Enter units to convert from into:
{{convert|1|lb|kg}}
→ pound 1 (kg 0.45)
- SI units generally accept prefixes, like "m" for milli (10−3), and "M" for mega (106)
- For "per" units, use "/" (slash): kg/ha
- For three-unit units, etc., see Category:Convert-like templates
Unit name or symbol (abbreviation): 1 pound or 1 lb?
[hariri chanzo]By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ pound 1 (kg 0.45)
Using |abbr=in
is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ lb 1 (kilogram 0.45)
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ lb 1 (kg 0.45){{convert|1|lb|kg|abbr=off}}
→ pound 1 (kilogram 0.45)
Convenience: {{cvt}} has |abbr=on
by default
[hariri chanzo]Template {{cvt}} is the same as {{convert}}, except that it has |abbr=on
as the default behaviour. In {{cvt}}, all other options are available. So:
{{cvt|1|lb|kg}}
→ lb 1 (kg 0.45)
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ lb 1 (kg 0.45)
Adjective: a 10-mile distance
[hariri chanzo]Use |adj=on
to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A -mile10 (km 16) distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ mile 10 (km 16) to go.
|adj=on
does not produce hyphens with unit symbols, as per :
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A in 9 (cm 23) nail.
Rounding: 100 ft is 30 m or 30.5 m or 30.48 m?
[hariri chanzo]By definition, 100 ft equals m 30.48. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
[hariri chanzo]By {{Convert}} 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 digits, whichever is more precise. An exception to this is rounding temperatures (see below).
Examples of rounding | ||
---|---|---|
Input | Displays as | Note |
{{convert|123|ft|m|-1}} |
feet 123 (m 40) | |
{{convert|123|ft|m}} |
feet 123 (m 37) | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
feet 123 (m 37) | |
{{convert|123|ft|m|1}} |
feet 123 (m 37.5) | |
{{convert|123|ft|m|2}} |
feet 123 (m 37.49) | The more-exact value is 37.4904 m or so, which gets converted to 37 m if this parameter is not specified at all. |
{{convert|500|ft|m|-1}} |
feet 500 (m 150) | |
{{convert|500|ft|m}} |
feet 500 (m 150) | same output as with −1 (above), because the conversion factor is between 0.2 and 2 (hence, it should produce same double-zero precision (−2) as in the input value), but the conversion must produce two significant digits at a minimum (hence, a higher single-zero precision (−1) is used) |
{{convert|500|ft|m|0}} |
feet 500 (m 152) | |
{{convert|500|ft|m|1}} |
feet 500 (m 152.4) | |
{{convert|500|ft|m|2}} |
feet 500 (m 152.40) | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
feet 500 (cm 15 000) | |
{{convert|500|ft|cm}} |
feet 500 (cm 15 000) | same output as with −3 (above), because the conversion factor is between 20 and 200 (hence, it should decrease input value's double-zero precision (−2) by 2), but the conversion must produce two significant digits at a minimum (hence, a higher triple-zero precision (−3) is used) |
{{convert|500|ft|cm|0}} |
feet 500 (cm 15 240) |
Convert supports four types of rounding:
Round to a given precision: use a precision number
[hariri chanzo]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 multiple of 1⁄10 to the power of 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: |sigfig=
[hariri chanzo]To specify the output number to be with n significant figures use |sigfig=<number>
:
{{convert|1200|ft|m|sigfig=4}}
→ feet 1 200 (m 365.8){{convert|1200|ft|m|sigfig=3}}
→ feet 1 200 (m 366){{convert|1200|ft|m|sigfig=2}}
→ feet 1 200 (m 370){{convert|1200|ft|m|sigfig=1}}
→ feet 1 200 (m 400)
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ feet 1 200 (m 370)
Setting |sigfig=
to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ feet 1 200 (m 370)*
Round to a multiple of 5: 15, 20, 25, ...
[hariri chanzo]Using |round=5
rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ metre 10 (ft 33){{convert|10|m|ft|round=5}}
→ metre 10 (ft 35)
Similar: using |round=25
rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ metre 10 (ft 33){{convert|10|m|ft|round=25}}
→ metre 10 (ft 25)
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ metre 10 (ft 32.81)
In a range, one can round each value individually to the default. Use |round=each
:
{{convert|10 x 200 x 3000|m|ft}}
→ metre 10 kwa 200 kwa 3 000 (ft ft 33 × ft 656 × 9 843){{convert|10 x 200 x 3000|m|ft|round=each}}
→ metre 10 kwa 200 kwa 3 000 (ft ft 33 × ft 660 × 9 800)
Round to a multiple of a given fraction: 2 3⁄16 inch
[hariri chanzo]Specify the desired denominator using |frac=<some positive integer>
. (Denominator is the below-the-slash number, for example the 3 in 1⁄3).
{{convert|5.56|cm|in|frac=16}}
→ sentimetre 5.56 (in 2 3⁄16){{convert|8|cm|in|frac=4}}
→ sentimetre 8 (in 3 1⁄4)
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ sentimetre 8 (in 3 3⁄20)
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ sentimetre 5.56 (in 2.19)
Rounding temperatures: °C, °F and K
[hariri chanzo]In temperatures, the conversion will be rounded either to the 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.
{{convert|10,000|C|F K}}
→ °C 10 000 (°F 18 000; K 10 300){{convert|10,000.1|C|F K}}
→ °C 10 000.1 (°F 18 032.2; K 10 273.2){{convert|-272|C|F K}}
→ °C −272 (°F −457.60; K 1.15){{convert|-272|C}}
→ °C −272 (°F −457.60){{convert|100|C|F K}}
→ °C 100 (°F 212; K 373){{convert|0|C|F K}}
→ °C 0 (°F 32; K 273)
The precision of the input number in example (1) is one digit, but the precision of its Kelvins expression is three, so the precision of the Fahrenheit conversion is made three (made 180...) . (1) and (2) seem to belie the fact that a degrees Celsius change 0.1 is a degrees Fahrenheit change 0.18, and make the 32 degrees difference shown in (1) begin to seem off somehow.
Result (1) seems off until you set the significant figures yourself with |sigfig=
:
{{convert|10000|C|sigfig=5}}
→ °C 10 000 (°F 18 032)
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
{{convert|10000|C|0}}
→ °C 10 000 (°F 18 032)
The precision of the input number in example (2) is six, so the precision of the Fahrenheit output is, whereas before, Kelvins had determined it to be three. Examples (3) and (4) show how this can be hidden and generate questions, but it occurs there because the Kelvins conversion generated two fractional parts. (Before it was the input number that generated the fractional part.) In example (3) the three input digits converted into five significant output digits because of the two digits after the decimal point, generated by the Kelvins conversion. This happened again in (5), but in (6) decimal fractions were neither given as input nor induced by the Kelvins conversion.
Rounding input
[hariri chanzo]There is limited support for rounding the displayed input number. The rounding takes place after conversion, so the output is based on the full-precision input. This is useful when the input is produced by {{#expr:}}
or otherwise available to a higher precision than is usefully displayed, and it's desirable to avoid double-rounding.
To round the input to a specified number of digits after the decimal point, use one of the parameters:
|adj=ri0
|adj=ri1
|adj=ri2
|adj=ri3
Note that there is no |adj=ri-1
or similar for rounding above the decimal place. Neither is there support for significant figures, multiples of 5, or any other output-rounding feature.
The default precision is computed based on the input, so an explicit output precision must usually be supplied:
{{convert|4.14159|mi|km|adj=ri0}}
→ mile 4 (km 6.66524) (precisions are mismatched){{convert|4.14159|mi|km|0|adj=ri0}}
→ mile 4 (km 7)
In this case, if the input were rounded before conversion, a different result would be obtained:
{{convert|{{#expr:4.14159 round 0}}|mi|km|0}}
→ mile 4 (km 6) (double rounding)
Into multiple units: °C 10 (°F 50; K 283)
[hariri chanzo]Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ °C 10 (°F 50; K 283){{convert|5|km|mi nmi}}
→ kilometre 5 (mi 3.1; nmi 2.7)
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see § In input and § In output.
Ranges of values
[hariri chanzo]A range converts two values and separates them by your choice of words and punctuation.
A range: 6 to 17 kg (13 to 37 lb)
[hariri chanzo]Range indicators are entered as the second parameter (between the values). Range separators can be:
Kigezo:Convert/doc/range separator list
Multiple dimensions: m m 6 × 12 (ft ft 20 × 39)
[hariri chanzo]Use by
:
{{convert|6|by|12|ft|m}}
→ feet 6 kwa 12 (m 1.8 kwa 3.7)
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ metre 6 kwa 12 (ft ft 20 × 39)
In science, the formal way is to set |x|
and |abbr=on
(keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ m m 6 × 12 (ft ft 20 × 39)
Lists of values: 20, 40, or 60 miles
[hariri chanzo]{{convert|20|,|40|, or|60|mi}}
→ mile 20, 40, au 60 (km 32, 64, au 97)
About feet, inch in ranges and multiples
[hariri chanzo]While it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ 1 foot 3 inches ([convert: unknown unit])*
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ 1 foot 3 inches (mm 380)
However, converting metric units into feet and inches with |order=flip
can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ 1 foot 3 inches kwa 3 feet 5 inches (mm mm 380 × 1 040)
Words
[hariri chanzo]Spelling of unit name: international metre or US meter?
[hariri chanzo]Default spelling of units is in the en (generic) locale. To show en-US spelling, use |sp=us
:
{{convert|1|m|ft}}
→ metre 1 (ft 3.3)—default{{convert|1|m|ft|sp=us}}
→ meter 1 (ft 3.3)
Spell out numbers: ten miles
[hariri chanzo]To write a number in words, use |spell=in
:
{{convert|10|mi|m|spell=in}}
→ mile ten (m 16 000)
To spell out both in and out values, use |spell=on
:
{{convert|10|mi|m|spell=on}}
→ mile ten (metre sixteen thousand)
To make first letter a capital, use |spell=In
, |spell=On
{{convert|10|mi|m|spell=In}}
→ mile Ten (m 16 000){{convert|10|mi|m|spell=On}}
→ mile Ten (metre sixteen thousand)
Remember that the spelling of the units (ft, m) is independently set by |abbr=
. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ mile ten (meter sixteen thousand)
Inserted before units: 4 planted acres
[hariri chanzo]{{convert|4|acre||adj=pre|planted}}
→ planted acre4 (ha 1.6)
disp=preunit
is similar, but has no separator after the specified text, and can have different text for the output value:
{{convert|4|acre||disp=preunit|planted }}
→ planted acre4 (planted ha1.6){{convert|4|acre||disp=preunit|planted |reforested-}}
→ planted acre4 (reforested- ha1.6)
After adjective unit: A -foot-long10 corridor
[hariri chanzo]Note that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
{{convert|10|ft|m|adj=mid|-long}}
→ -foot-long10 (m 3.0)
Plurals: 1 inch, 2 inches
[hariri chanzo]The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ metre 1 (3 ft 3 in){{convert|2|metre}}
→ metre 2 (6 ft 7 in){{convert|2|metre|abbr=on}}
→ m 2 (6 ft 7 in)
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ foot 100 (metre 30)
Fractions: one-eighth of an imperial pint
[hariri chanzo]The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ ounce three and a half (g 99)
Any additional words needed for the fraction can also be added at the end of the template.
{{convert|1/8|imppt|ml|spell=in|adj=pre|of an}}
→ of an imperial pintone-eighth (ml 71)
Wrapping and line breaking
[hariri chanzo]Spelling out "thousands", "millions", etc.
[hariri chanzo]Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ mile 100 million (km 160×10 6){{convert|120|e6acre}}
→ acre 120 million (km2 490 000){{convert|120|e6acre|e3km2}}
→ acre 120 million (km2 490×10 3)
To display both input and output in scientific notation, use |abbr=on
{{convert|100|e6mi|e6km|abbr=on}}
→ mi 100×10 6 (km 160×10 6)
To spell out "thousands", "millions", etc., |abbr=unit
abbreviates the unit; |abbr=off
displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ mi 100 million (km 160 million){{convert|100|e6mi|e6km|abbr=off}}
→ mile 100 million (kilometre 160 million)
Numbers
[hariri chanzo]Using an SI prefix: gigametre (Gm), or micrometre (μm)
[hariri chanzo]Kigezo:Sidebar metric prefixes (small)
Units can have an SI prefix like G
before the unit: Gm
, and giga
before the name: gigametre
. These are plain multiplication factors.
To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
- Gm 12 (m 1.2×1010)
- μm 12 (m 1.2×10−5)
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Gm 12 (mi 7 500 000)Mm
: Mm 12 (mi 7 500)km
: km 12 (ft 39 000)mm
: mm 12 (in 0.47)μm
: μm 12 (mm 0.012)um
: μm 12 (mm 0.012) (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ mi 12 000 (Mm 19){{convert|12|in|μm|abbr=on}}
→ in 12 (μm 300 000)
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ μm 12 (μin 470)
Engineering notation: 7 × 106 m
[hariri chanzo]In the unit: e6m
[hariri chanzo]Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ m 70×10 6 (ft 230 000 000)
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ feet 23 000 000 (m 7.0×10 6)
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
e3
(thousand),e6
(million),e9
(billion),e12
(trillion),e15
(quadrillion).
Scientific notation: 1.23 × 10−14
[hariri chanzo]In scientific notation, a number is written like 1.23×10−14. The plain number has exactly one digit before the decimal point.
With {{convert}}, the input can be in e-notation such as 12.3e4
. This value is displayed as a power of ten, and the output is displayed in scientific notation, except that an output value satisfying 0.01 <= v < 1000 is shown as a normal number. In addition, if the output value is 1000 and sigfig=4 is used, the value is displayed as a normal number.
{{convert|12.3e-15|atm|atm|abbr=on}}
→ atm 12.3×10−15 (atm 1.23×10−14){{convert|0.00000005|atm|atm|abbr=on}}
→ atm 0.00000005 (atm 5.0×10−8)
Input with fractions: inches 1 1⁄2 (mm 38.1)
[hariri chanzo]The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ inch 1⁄2 (mm 12.7){{convert|1⁄2|in|mm|1}}
→ inch 1⁄2 (mm 12.7)
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ inches 2 1⁄2 (mm 63.5)
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ inches −2 1⁄2 (mm −63.5)
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ inch 2–1⁄2 (mm 50.8–12.7). This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ [convert: invalid number] This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: 1/2 inch
[hariri chanzo]Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ inch 1/2 (mm 12.7){{convert|6+3//8|in|mm|1}}
→ inches 6 3/8 (mm 161.9)
Using a negative value for |frac=
provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ milimetre 12.7 (in 1/2){{convert|161.9|mm|frac=-8}}
→ milimetre 161.9 (in 6 3/8)
Thousands separator: 1,000 mi or 1000 mi
[hariri chanzo]In input, a comma for thousands separator is accepted but not required; a gap (space) is not accepted. In output, by default, the thousand separator is the comma:
{{convert|1234567|m|ft}}
→ metre 1 234 567 (ft 4 050 417){{convert|1,234,567|m|ft}}
→ metre 1 234 567 (ft 4 050 417)
Set |comma=off
to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ metre 1234567 (ft 4050417)
Use |comma=gaps
to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ metre 1234567 (ft 4050417)
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ metre 1 234 567 (ft 4 050 417)
Setting |comma=5
will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ metre 1234 (ft 4049){{convert|1234567|m|ft|comma=5}}
→ metre 1 234 567 (ft 4 050 417)
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ metre 1 234 (ft 4 049)
Output manipulation
[hariri chanzo]Brackets and separators: 10 m [33 ft]
[hariri chanzo]Punctuation that distinguishes the two measurements is set by |disp=
.
Options are: b
(the default), sqbr
, comma
, or
, br
, br()
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ metre 10 [ft 33]{{convert|10|m|ft|disp=comma}}
→ metre 10, ft 33{{convert|10|m|ft|disp=or}}
→ metre 10 au feet 33
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ metre 10 (ft 33)
Setting |disp=br
will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ metre 10
feet 33
Also |disp=br()
will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ metre 10
(feet 33)
Setting |disp=x|…
allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ metre 10_MyText_ft 33 (To display spaces, use
)
Flipping (reordering) the two measurements: metre 1 609.3 (mile 1)
[hariri chanzo]Setting |order=flip
will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ metre 1 609.3 (mile 1)
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ mile 1 (metre 1 609.3)
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ mile 6.2137; nautical mile 5.3996 (kilometre 10){{convert|10|km|nmi mi|order=flip}}
→ nautical mile 5.3996; mile 6.2137 (kilometre 10)
Fixed ordering of output units: °F 212 (°C 100; K 373)
[hariri chanzo]Setting |order=out
shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ °F 212 (°C 100; K 373){{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ kW 147 (hp 197)
See also: § Displaying parts of the output.
Displaying parts of the result: 2 (1.5)
[hariri chanzo]It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
cubic yard 2 (m3 1.5) | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
2 (1.5) | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
cubic yard | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
cubic-yard | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
cu yd 2.0 | Input (workaround. Note repetition of unit in input) |
{{convert|2|cuyd|m3|abbr=~}} |
cubic yard 2 [cu yd] (m3 1.5) | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
m3 | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
cubic metre | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
1.5 | Output value |
{{convert|2|cuyd|m3|disp=out}} |
m3 1.5 | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
cubic metre 1.5 | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
[hariri chanzo]Setting |abbr=~
returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ kilopascal 2 [kPa] (psi 0.29)A {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ A -kilopascal2 [kPa] (psi 0.29) pressure
Table options
[hariri chanzo]For the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable.
Enforced line break
[hariri chanzo]|disp=br
adds a line-break and omits brackets.
|disp=br()
adds a line-break and does add brackets to the converted value. This may be useful in tables:
|disp=br |
|disp=br()
|
---|---|
kilometre 100 mile 62 |
kilometre 100 (mile 62) |
Table columns
[hariri chanzo]Using {convert} in a table cell, with |disp=table
splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the |abbr=
parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
style="text-align:right;"|10
|style="text-align:right;"|33
|disp=tablecen
does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
style="text-align:center;"|20
|style="text-align:center;"|66
The units are added as a column header:
kilograms pounds stone and pounds |disp=table
10 22 1 st 8 lb |disp=table
and|abbr=on
kg 20 lb 44 3 st 2 lb |disp=table
and|abbr=off
kilogram 30 pound 66 4 stone 10 pound |disp=tablecen
40 88 6 st 4 lb |disp=<other>
(default)kilogram 50 (lb 110; 7 st 12 lb)
Sorting
[hariri chanzo]Use |sortable=on
to include a hidden numerical sortkey in the output, suitable for use in a table with sortable columns. Technically, this places a hidden string before the actual displayed values:
{{convert|10|m|ft|sortable=on}}
→<span data-sort-value="7001100000000000000♠"></span>10 metres (33 ft)
- showing: metre 10 (ft 33).
Use both |disp=table
and |sortable=on
together to produce table columns (pipe symbols) for each value in sortable columns:
m m ft A Kigezo:Val 15 3⁄4 52 B Kigezo:Val 15.5 51 C Kigezo:Val 16.0 52.5 D Kigezo:Val 16 52
The generated sortkey is calculated in a consistent way based on both the value and its unit as passed to the convert template. In most cases convert uses the passed value converted to SI base units. It is therefore not necessarily the displayed value or other alternate units and is calculated regardless of output format options. Using different units or different order of units in individual rows should therefore not lead to incorrect sorting, although variations in rounding can give surprising results, since an unrounded number is used for the sortkey.
Units
[hariri chanzo]The conversion factors and physical constants are sourced here.
All units
[hariri chanzo]The table below lists units supported by {{convert}}. More complete lists are linked for each dimension. For a complete list of all dimensions, see full list of units.