Lompat ke isi

Citakan:Convert/doc

Ti Wikipédia Sunda, énsiklopédi bébas

Citakan:Transwiki guide

Template {{convert}} calculates measurements from one unit (you entered) to another one, and then presents the results. For example:

{{convert|2|km|mi}} → 2 kilometres (1.2 mi)
{{convert|7|mi|km}} → 7 miles (11 km)

Unit name or symbol (abbreviation): 1 pound or 1 lb?

[édit sumber]

The 'abbreviation' is actually the 'symbol'. |abbr=on will produce the symbol of the unit, instead of its name:

{{convert|1|lb|kg}} → 1 pound (0.45 kg) -- to compare
{{convert|1|lb|kg|abbr=on}} → 1 lb (0.45 kg)

Adjective: a 10-mile distance

[édit sumber]

Use |adj=on to produce the adjective form. The difference:

{{convert|10|mi|km}} to go → 10 miles (16 km) to go. -- to compare
A {{convert|10|mi|km|adj=on}} distance → A 10-mile (16 km) distance. -- Adjective

Rounding: 100 ft is 30 m or 30.5 m or 30.48 m?

[édit sumber]

In detail, it is 100 feet (30,480 mm)*. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.

Default rounding

[édit sumber]
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).
Examples of rounding
Input Displays as Note
{{convert|123|ft|m|-1}} 123 feet (40 m)
{{convert|123|ft|m|0}} 123 feet (37 m)
{{convert|123|ft|m|1}} 123 feet (37.5 m)
{{convert|550|ft|m|0}} 550 feet (168 m) Approximate value is 167.64 m
{{convert|550|ft|m}} 550 feet (170 m) Rounds to 170, when approximate value is 167.64 m
{{convert|500|ft|m|0}} 500 feet (152 m) Approximate value is 152.4 m
{{convert|500|ft|m}} 500 feet (150 m) Rounds to 150, when approximate value is 152.4 m

Convert supports four types of rounding:

Round to a given precision: use |precision=

[édit sumber]

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 110 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=

[édit sumber]

Specify the desired number of significant figures using |sigfig=<number> as noted above.

Round to a multiple of 5: 15, 20, 25, ...

[édit sumber]

Using |round=5 rounds the outcome to a multiple of 5. Same as |near=5 and |disp=5.

{{convert|10|m|ft}} → 10 metres (33 ft)
{{convert|10|m|ft|round=5}} → 10 metres (35 ft)

Similar: using |round=25 rounds the outcome to a multiple of 25.

{{convert|10|m|ft}} → 10 metres (33 ft)
{{convert|10|m|ft|round=25}} → 10 metres (25 ft)
To compare: {{convert|10|m|ft|sigfig=4}} → 10 metres (32.81 ft)

In a range, one can round each value individually to the default. Use |round=each:

{{convert|10 x 200 x 3000|m|ft|round=each}} → 10 by 200 by 3,000 metres (33 ft × 660 ft × 9,800 ft)
{{convert|10 x 200 x 3000|m|ft}} → 10 by 200 by 3,000 metres (33 ft × 656 ft × 9,843 ft)

Round to a multiple of a given fraction: 2+14 inch

[édit sumber]

Specify the desired denominator using |frac=<some positive integer>. (Denominator is the below-the-slash number, for example the 3 in 13).

{{convert|6|cm|in|frac=2}} → 6 centimetres (2 12 in)
{{convert|6|cm|in|frac=4}} → 6 centimetres (2 14 in)
{{convert|6|cm|in|frac=100}} → 6 centimetres (2 925 in)
To compare: {{convert|6|cm|in}} → 6 centimetres (2.362 in)

Rounding temperatures °C, °F and K

[édit sumber]

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.

{{convert|10|C|F K}} → 10 °C (50 °F; 283 K)

Note

For a temperature difference, like to convert "a rise of 20 °C", use |C-change=20 &tc.
{{convert|20|C-change|F-change K-change}} → A rise of 20 °C (36 °F; 20 K)

Into multiple units: 10 °C (50 °F; 283 K)

[édit sumber]

Separate the multiple output units by a space:

{{convert|10|C|F K}} → 10 °C (50 °F; 283 K)
{{convert|5|km|mi nmi}} → 5 kilometres (3.1 mi; 2.7 nmi)

Multiple measurements

[édit sumber]

Range of values: 6 to 17 kg (13 to 37 lb)

[édit sumber]

Range indicators are entered as the second parameter (between the values). Range separators can be:

to, to(-), - (ndash or hyphen), or, and, ±, +/-:
{{convert|6|to|17|kg|lb|abbr=on}} → 6 to 17 kg (13 to 37 lb)
{{convert|-10|to|-20|C}} → −10 to −20 °C (14 to −4 °F)
{{convert|6|to(-)|17|kg|lb}} → 6 to 17 kilograms (13–37 lb)
{{convert|6|and|17|kg|lb}} → 6 and 17 kilograms (13 and 37 lb)
{{convert|60|±|10|m|ft}} → 60 ± 10 metres (197 ± 33 ft)
{{convert|60|+/-|10|m|ft}} → 60 ± 10 metres (197 ± 33 ft)

Multiple dimensions: 6 by 12 feet (1.8 by 3.7 m)

[édit sumber]
{{convert|6|by|12|ft|m}} → 6 by 12 feet (1.8 by 3.7 m)
{{convert|6|x|12|m|ft}} → 6 by 12 metres (20 ft × 39 ft)

About feet, inch multiples

[édit sumber]

It is not possible to produce multiple [feet, inch] measurements.

Spell out numbers: ten miles

[édit sumber]

To write a number in words, use |spell=in:

{{convert|10|mi|m|spell=in}} → ten miles (16,000 m)

To spell out both in and out values, use |spell=on:

{{convert|10|mi|m|spell=on}} → ten miles (sixteen thousand metres)

To make first letter a capital, use |spell=In, |spell=On

{{convert|10|mi|m|spell=In}} → Ten miles (16,000 m)
{{convert|10|mi|m|spell=On}} → Ten miles (sixteen thousand metres)

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}} → ten miles (sixteen thousand meters)

Spelling of units: UK metre or US meter?

[édit sumber]

Default spelling of units is en-UK. To show en-US spelling, use |sp=us:

{{convert|1|m|ft}} → 1 metre (3.3 ft) -- default
{{convert|1|m|ft|sp=us}} → 1 meter (3.3 ft)

Extra words: 4 planted acres

[édit sumber]
Incomplete secion:
{{convert|4|acre||adj=pre|planted}} → 4 planted acres (1.6 ha)

Extra adjective words: A 10-foot-long (3.0 m) corridor

[édit sumber]
{{convert|4|ft| |adj=mid|-long}} → 10-foot-long (3.0 m)

Numbers in

[édit sumber]

Fractions: 12 inch (12.7 mm)

[édit sumber]

The number to convert can be expressed in fractions:

{{convert|1/2|in|mm|1}}12 inch (12.7 mm)

Also the "⁄" punctuation is accepted (&frasl;)

{{convert|1⁄2|in|mm|1}}12 inch (12.7 mm)

Engineering notation: e6m

[édit sumber]

Common engineering notations like e6 (106) are to be put with the unit:

{{convert|9|e6m}} →9 million metres (30,000,000 ft)

See also: {{val}}

Numbers out

[édit sumber]
to be added

Output manipulation

[édit sumber]

Brackets and separators: 10 m [33 ft]

[édit sumber]

Punctuation that distinguishes the two measurements is set by |disp=.
Options are: b (the default), sqbr, / (or: s, slash), comma, or, br, x|...:

{{convert|10|m|ft}} → 10 metres (33 ft) -- ( ) brackets are the default
{{convert|10|m|ft|disp=sqbr}} → 10 metres [33 ft]
{{convert|10|m|ft|disp=slash}} → 10 m (33 ft)*
{{convert|10|m|ft|disp=comma}} → 10 metres, 33 ft
{{convert|10|m|ft|disp=or}} → 10 metres or 33 feet

Setting |disp=br will force a new line (<br>)

{{convert|10|m|ft|disp=br}} → 10 metres
33 feet

Setting |disp=x extra parameter (separator) to add:

{{convert|10|m|ft|disp=x|_MyText_}} → 10 metres_MyText_33 ft -- (Take care of the spaces, use &nbsp;)

Converted measurement only: 6.2 mi

[édit sumber]

Setting |disp=out returns the calculated measurement only:

{{convert|10|km|mi|disp=out}} → 6.2 mi
{{convert|10|km|mi|disp=u2}} → 10 kilometres (6.2 mi)*

Converted number only: 6.2

[édit sumber]

Setting |disp=number returns the converted number only:

{{convert|10|km|mi|disp=number}} → 6.2

Unit only: kilometres

[édit sumber]

Setting |disp=unit returns the (input) unit only:

{{convert|10|km|mi|disp=unit}} → kilometres

Flipping the two measurements: 1,609.3 metres (1 mile)

[édit sumber]

Set |disp=flip will flip (swap) the two measurements:

{{convert|1|mi|m|disp=flip}} → 1,609.3 metres (1 mile)

Table options

[édit sumber]

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

Result split over columns in a table

[édit sumber]

Using {convert} in a table cell, with |disp=table splits the result over two columns:

{{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:

m ft
|disp=table 10 33
|disp=tablecen 20 66
|disp=<other> (default) 30 metres (98 ft)

Sorting

[édit sumber]
Use both |disp=table |sortable=on to make a table column sortable. Only the first column will sort correct.
{{convert|10|m|ft|disp=table|sortable=on}} → (don't let this frighten you)

style="text-align:right;" data-sort-value="7001100000000000000"|10 |style="text-align:right;" data-sort-value="7001100000000000000"|33

m ft
10 33
20 66
30 98

US gallons

[édit sumber]
more to follow

Units overview

[édit sumber]
See also: complete Convert/list of units

The table below lists units supported by template {{convert}}. It is subdivided by the dimension of the measurement, such as length, area, and power. The list is not complete, more complete lists are linked for each dimension. A complete list is at the full list of units.

The unit-code (column 3), is accepted as input by the template. These can be used as the second or third unnamed parameter. Some units have alternative codes; these are shown in brackets e.g. °F (F): each may be entered for Fahrenheit.

Column 7 lists possible combinations of multiple converted outputs. E.g. {{convert|55|nmi|km mi}} produces "55 nautical miles (102 km; 63 mi)". Such a combination must be used as the third unnamed parameter.

Abridged list of units supported by {{Convert}}
Explanation
system unit unit-
code
symbol or
abbrev.
notes sample default
conversion
combination
output units
the system(s) to which the unit belongs units listed by name unit-code to use in template symbols shown in output other notes about the units sample of the default conversion for the unit output codes for multiple conversions


LENGTH
(Full list)
system unit unit-
code
abbrev-
iation
notes sample default
conversion
combination
output units
SI megametre Mm Mm US spelling: megameter
1.0 Mm (620 mi)
kilometre km km US spelling: kilometer
1.0 km (0.62 mi)
  • km mi
metre m m US spelling: meter
1.0 m (3 ftin)
  • m ft
  • m ftin
centimetre cm cm US spelling: centimeter
1.0 cm (0.39 in)
  • cm in
millimetre mm mm US spelling: millimeter
1.0 mm (0.039 in)
  • mm in
micrometre μm (um) μm US spelling: micrometer
1.0 μm (3.9×10−5 in)
nanometre nm nm US spelling: nanometer
1.0 nm (3.9×10−8 in)
non-SI metric ångström Å
(angstrom)
Å 1.0 Å (3.9×10−9 in)
Imperial
&
US customary
mile mi mi 1.0 mi (1.6 km)
  • mi km
furlong furlong (none) 1.0 furlong (660 ft; 200 m)
chain chain (none) 1.0 chain (66 ft; 20 m)
rod rd rd For other names of this unit see the full list. 1.0 rd (17 ft; 5.0 m)
fathom fathom (none) assumes 1 fathom ≡ 6 ft 1.0 fathom (6.0 ft; 1.8 m)
yard yd yd assumes the international definition 1.0 yd (0.91 m)
foot ft (foot) ft Citakan:Convert/list of units/foot note 1.0 ft (0.30 m)
  • ftin (feet and inches)
  • ft m (foot m)
inch in in 1.0 in (25 mm)
  • in cm
  • in mm
Other nautical mile nmi nmi the international standard nautical mile
For other nautical miles see the full list.
1.0 nmi (1.9 km; 1.2 mi)
parsec pc pc 1.0 pc (3.3 ly)
light-year ly ly 1.0 ly (63,000 AU)
astronomical unit AU AU 1.0 AU (150,000,000 km; 93,000,000 mi)

Citakan:Convert/list of units/area/short list Citakan:Convert/list of units/volume/short list Citakan:Convert/list of units/speed/short list Citakan:Convert/list of units/force/short list Citakan:Convert/list of units/energy/short list Citakan:Convert/list of units/temperature/short list Citakan:Convert/list of units/mass/short list Citakan:Convert/list of units/torque/short list Citakan:Convert/list of units/density/short list Citakan:Convert/list of units/extra

Parameter list

[édit sumber]
Option Description
|abbr=comma No comma in input or output numbers.
|abbr=in Use symbol for LHS unit.
|abbr=off Use name for all units.
|abbr=on Use symbol for all units.
|abbr=out Use symbol for RHS unit (default).
|abbr=values Show only input and output numbers, not units.
|abbr=~ Show input unit symbol as well as name.
|adj=1 Unit name is singular when value is 1 or less, but not zero.
|adj=flip Reverse order of input/output.
|adj=j Join value and unit name using "&nbsp;" instead of a space.
|adj=mid Same as adj=on with user-specified text after input unit.
|adj=nocomma No comma in input or output numbers.
|adj=on Unit name is singular and hyphenated.
|adj=pre User-specified text before input unit.
|adj=ri1 Round input with precision 1.
|adj=ri2 Round input with precision 2.
|adj=ri3 Round input with precision 3.
|disp=/ Join input/output using "/".
|disp=2 Display only output value and symbol/name.
|disp=5 Round output value to nearest 5.
|disp=b Join input/output using "(...)".
|disp=br Join input/output using "<br/>".
|disp=comma Join input/output using ",".
|disp=flip Reverse order of input/output.
|disp=flip5 Same as disp=flip with disp=5.
|disp=nocomma No comma in input or output numbers.
|disp=number Display output value only.
|disp=or Join input/output using "or".
|disp=out Same as disp=2.
|disp=output number only Same as disp=number.
|disp=output only Same as disp=2.
|disp=preunit User-specified text before input and output units.
|disp=s Same as disp=/.
|disp=slash Same as disp=/.
|disp=sqbr Join input/output using "[...]".
|disp=table Output is suitable for a table cell with align="right".
|disp=tablecen Output is suitable for a table cell with align="center".
|disp=u2 Display output symbol/name (not input; not output value).
|disp=unit Display input symbol/name (not output; not input value).
|disp=unit2 Same as disp=u2.
|disp=x Join input/output using user-specified text.
|comma=5 Only use comma grouping if 5 or more digits.
|comma=gaps Use gaps, not comma, to separate groups of digits.
|comma=gaps5 Use gaps, but only if 5 or more digits.
|debug=yes Make the normally hidden sort key visible.
|frac=N Display the output as fractions with N as the largest denominator.
|lk=in Link LHS unit name or symbol.
|lk=on Link all unit names or symbols (but not twice for the same unit).
|lk=out Link RHS unit name or symbol.
|sigfig=N Round output value to N significant figures (N is a positive integer).
|sortable=on Output numeric hidden sort field for use in a sortable table.
|sp=us Use U.S. spelling (like "meter" instead of default "metre").
|spell=in Spell input value in words.
|spell=In Spell input value in words with first letter uppercase.
|spell=on Spell input and output values in words.
|spell=On Spell input and output values in words with first letter uppercase.

Examples of number grouping:

  • {{convert|1234|m|ft}} → 1,234 metres (4,049 ft)
  • {{convert|1234|m|ft|comma=5}} → 1234 metres (4049 ft)
  • {{convert|12345|m|ft|comma=5}} → 12,345 metres (40,502 ft)
  • {{convert|1234|m|ft|comma=gaps}}1234 metres (4049 ft)
  • {{convert|1234|m|ft|comma=gaps5}} → 1,234 metres (4,049 ft)*
  • {{convert|123,456,789|m|ft|comma=gaps5}} → 123,456,789 metres (405,041,959 ft)*

Examples of spelling input values:

  • {{convert|10|mi|km|spell=in}} → ten miles (16 km)
  • {{convert|10|mi|km|spell=In}} → Ten miles (16 km)
  • {{convert|1/3|mi|km|adj=on|spell=in}} → one-third-mile (0.54 km)

Options not supported

[édit sumber]

Free text in a range: 12 m but not greater than 14 m

[édit sumber]

{{|tl|convert}} does not cover free text in range descriptions. For these cases, one can calculate the numbers using convert, and then hardcode the numbers in a page with text added.

TemplateData

[édit sumber]
This is the TemplateData documentation for this template used by VisualEditor and other tools.

Convert

Converts measurements to other units.

Parameter templat

ParameterKeteranganJenisStatus
value1

the value to convert

Angkaopsional
from unit2

Barisopsional
to units3

Barisopsional
precision or suffix4

significant digits after decimal dot or, if negative, exponent of ten

Angkaopsional
link unitslk

“on” all, “in” input, “out” output or “off” no units

Baku
off
Barisopsional
abbreviationabbr

show “on” unit symbols, “off” all unit names in full words, “in” abbreviated input units, “out” abbreviated output units or “values” no unit names

Barisopsional
spellingsp

“us” US

Barisopsional
adjectiveadj

adjective form (singular unit name appended by hyphen) “on” or “mid” to put conversion at end

Barisopsional
conversiondisp

show conversion … “or” after ‘or’, “b” in parentheses, “x” with custom prefix and suffix, “table”/“tablecen”, “output only” alone, “output number only” alone and without unit, “flip” first, “unit” not at all but input unit; if the value is a number it is used as precision

Baku
b
Barisopsional
significant figuressigfig

number that sets the number of significant figures

Angkaopsional
sort keysortable

“on” generates a hidden sort key

Barisopsional

Glossary

[édit sumber]
todo
  • Dimension:
  • Significant figures, Sigfig:

See also

[édit sumber]

Galat Lua: bad argument #2 to 'title.new' (unrecognized namespace name 'Templat').