Template:Convert
Template:Documentation subpage Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Contents
- 1 Units to convert
- 2 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 3 Adjective: a 10-mile distance
- 4 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 4.1 Default rounding
- 4.2 Round to a given precision: use a precision number
- 4.3 Round to a given number of significant figures: Template:Para
- 4.4 Round to a multiple of 5: 15, 20, 25, ...
- 4.5 Round to a multiple of a given fraction: Template:Frac inch
- 4.6 Template:AnchorRounding temperatures: °C, °F and K
- 4.7 Rounding input
- 5 Into multiple units: Template loop detected: Template:Convert
- 6 Ranges of values
- 7 Words
- 7.1 Spelling of unit name: international metre or US meter?
- 7.2 Spell out numbers: ten miles
- 7.3 Inserted before units: 4 planted acres
- 7.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 7.5 Plurals: 1 inch, 2 inches
- 7.6 Fractions: one-eighth of an imperial pint
- 7.7 Wrapping and line breaking
- 7.8 Spelling out "thousands", "millions", etc.
- 8 Numbers
- 9 Output manipulation
- 9.1 Brackets and separators: 10 m [33 ft]
- 9.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 9.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 9.4 Displaying parts of the result: Template loop detected: Template:Convert
- 9.5 Display both input name and symbol: 2 kilopascals [kPa]
- 10 Table options
- 11 Units
- 12 Using convert inside templates
- 13 Parameter list
- 14 Deprecated options
- 15 TemplateData
- 16 See also
- 17 Units to convert
- 18 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 19 Adjective: a 10-mile distance
- 20 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 20.1 Default rounding
- 20.2 Round to a given precision: use a precision number
- 20.3 Round to a given number of significant figures: Template:Para
- 20.4 Round to a multiple of 5: 15, 20, 25, ...
- 20.5 Round to a multiple of a given fraction: Template:Frac inch
- 20.6 Template:AnchorRounding temperatures: °C, °F and K
- 20.7 Rounding input
- 21 Into multiple units: Template loop detected: Template:Convert
- 22 Ranges of values
- 23 Words
- 23.1 Spelling of unit name: international metre or US meter?
- 23.2 Spell out numbers: ten miles
- 23.3 Inserted before units: 4 planted acres
- 23.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 23.5 Plurals: 1 inch, 2 inches
- 23.6 Fractions: one-eighth of an imperial pint
- 23.7 Wrapping and line breaking
- 23.8 Spelling out "thousands", "millions", etc.
- 24 Numbers
- 25 Output manipulation
- 25.1 Brackets and separators: 10 m [33 ft]
- 25.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 25.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 25.4 Displaying parts of the result: Template loop detected: Template:Convert
- 25.5 Display both input name and symbol: 2 kilopascals [kPa]
- 26 Table options
- 27 Units
- 28 Using convert inside templates
- 29 Parameter list
- 30 Deprecated options
- 31 TemplateData
- 32 See also
- 33 Units to convert
- 34 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 35 Adjective: a 10-mile distance
- 36 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 36.1 Default rounding
- 36.2 Round to a given precision: use a precision number
- 36.3 Round to a given number of significant figures: Template:Para
- 36.4 Round to a multiple of 5: 15, 20, 25, ...
- 36.5 Round to a multiple of a given fraction: Template:Frac inch
- 36.6 Template:AnchorRounding temperatures: °C, °F and K
- 36.7 Rounding input
- 37 Into multiple units: Template loop detected: Template:Convert
- 38 Ranges of values
- 39 Words
- 39.1 Spelling of unit name: international metre or US meter?
- 39.2 Spell out numbers: ten miles
- 39.3 Inserted before units: 4 planted acres
- 39.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 39.5 Plurals: 1 inch, 2 inches
- 39.6 Fractions: one-eighth of an imperial pint
- 39.7 Wrapping and line breaking
- 39.8 Spelling out "thousands", "millions", etc.
- 40 Numbers
- 41 Output manipulation
- 41.1 Brackets and separators: 10 m [33 ft]
- 41.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 41.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 41.4 Displaying parts of the result: Template loop detected: Template:Convert
- 41.5 Display both input name and symbol: 2 kilopascals [kPa]
- 42 Table options
- 43 Units
- 44 Using convert inside templates
- 45 Parameter list
- 46 Deprecated options
- 47 TemplateData
- 48 See also
- 49 Units to convert
- 50 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 51 Adjective: a 10-mile distance
- 52 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 52.1 Default rounding
- 52.2 Round to a given precision: use a precision number
- 52.3 Round to a given number of significant figures: Template:Para
- 52.4 Round to a multiple of 5: 15, 20, 25, ...
- 52.5 Round to a multiple of a given fraction: Template:Frac inch
- 52.6 Template:AnchorRounding temperatures: °C, °F and K
- 52.7 Rounding input
- 53 Into multiple units: Template loop detected: Template:Convert
- 54 Ranges of values
- 55 Words
- 55.1 Spelling of unit name: international metre or US meter?
- 55.2 Spell out numbers: ten miles
- 55.3 Inserted before units: 4 planted acres
- 55.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 55.5 Plurals: 1 inch, 2 inches
- 55.6 Fractions: one-eighth of an imperial pint
- 55.7 Wrapping and line breaking
- 55.8 Spelling out "thousands", "millions", etc.
- 56 Numbers
- 57 Output manipulation
- 57.1 Brackets and separators: 10 m [33 ft]
- 57.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 57.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 57.4 Displaying parts of the result: Template loop detected: Template:Convert
- 57.5 Display both input name and symbol: 2 kilopascals [kPa]
- 58 Table options
- 59 Units
- 60 Using convert inside templates
- 61 Parameter list
- 62 Deprecated options
- 63 TemplateData
- 64 See also
- 65 Units to convert
- 66 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 67 Adjective: a 10-mile distance
- 68 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 68.1 Default rounding
- 68.2 Round to a given precision: use a precision number
- 68.3 Round to a given number of significant figures: Template:Para
- 68.4 Round to a multiple of 5: 15, 20, 25, ...
- 68.5 Round to a multiple of a given fraction: Template:Frac inch
- 68.6 Template:AnchorRounding temperatures: °C, °F and K
- 68.7 Rounding input
- 69 Into multiple units: Template loop detected: Template:Convert
- 70 Ranges of values
- 71 Words
- 71.1 Spelling of unit name: international metre or US meter?
- 71.2 Spell out numbers: ten miles
- 71.3 Inserted before units: 4 planted acres
- 71.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 71.5 Plurals: 1 inch, 2 inches
- 71.6 Fractions: one-eighth of an imperial pint
- 71.7 Wrapping and line breaking
- 71.8 Spelling out "thousands", "millions", etc.
- 72 Numbers
- 73 Output manipulation
- 73.1 Brackets and separators: 10 m [33 ft]
- 73.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 73.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 73.4 Displaying parts of the result: Template loop detected: Template:Convert
- 73.5 Display both input name and symbol: 2 kilopascals [kPa]
- 74 Table options
- 75 Units
- 76 Using convert inside templates
- 77 Parameter list
- 78 Deprecated options
- 79 TemplateData
- 80 See also
- 81 Units to convert
- 82 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 83 Adjective: a 10-mile distance
- 84 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 84.1 Default rounding
- 84.2 Round to a given precision: use a precision number
- 84.3 Round to a given number of significant figures: Template:Para
- 84.4 Round to a multiple of 5: 15, 20, 25, ...
- 84.5 Round to a multiple of a given fraction: Template:Frac inch
- 84.6 Template:AnchorRounding temperatures: °C, °F and K
- 84.7 Rounding input
- 85 Into multiple units: Template loop detected: Template:Convert
- 86 Ranges of values
- 87 Words
- 87.1 Spelling of unit name: international metre or US meter?
- 87.2 Spell out numbers: ten miles
- 87.3 Inserted before units: 4 planted acres
- 87.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 87.5 Plurals: 1 inch, 2 inches
- 87.6 Fractions: one-eighth of an imperial pint
- 87.7 Wrapping and line breaking
- 87.8 Spelling out "thousands", "millions", etc.
- 88 Numbers
- 89 Output manipulation
- 89.1 Brackets and separators: 10 m [33 ft]
- 89.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 89.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 89.4 Displaying parts of the result: Template loop detected: Template:Convert
- 89.5 Display both input name and symbol: 2 kilopascals [kPa]
- 90 Table options
- 91 Units
- 92 Using convert inside templates
- 93 Parameter list
- 94 Deprecated options
- 95 TemplateData
- 96 See also
- 97 Units to convert
- 98 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 99 Adjective: a 10-mile distance
- 100 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 100.1 Default rounding
- 100.2 Round to a given precision: use a precision number
- 100.3 Round to a given number of significant figures: Template:Para
- 100.4 Round to a multiple of 5: 15, 20, 25, ...
- 100.5 Round to a multiple of a given fraction: Template:Frac inch
- 100.6 Template:AnchorRounding temperatures: °C, °F and K
- 100.7 Rounding input
- 101 Into multiple units: Template loop detected: Template:Convert
- 102 Ranges of values
- 103 Words
- 103.1 Spelling of unit name: international metre or US meter?
- 103.2 Spell out numbers: ten miles
- 103.3 Inserted before units: 4 planted acres
- 103.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 103.5 Plurals: 1 inch, 2 inches
- 103.6 Fractions: one-eighth of an imperial pint
- 103.7 Wrapping and line breaking
- 103.8 Spelling out "thousands", "millions", etc.
- 104 Numbers
- 104.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 104.2 Engineering notation: 7 × 106 m
- 104.3 Scientific notation: 1.23 × 10−14
- 104.4 Input with fractions: Template loop detected: Template:Convert
- 104.5 Horizontal fraction bar: Template:Sfrac inch
- 104.6 Thousands separator: 1,000 mi or 1000 mi
- 105 Output manipulation
- 105.1 Brackets and separators: 10 m [33 ft]
- 105.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 105.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 105.4 Displaying parts of the result: Template loop detected: Template:Convert
- 105.5 Display both input name and symbol: 2 kilopascals [kPa]
- 106 Table options
- 107 Units
- 108 Using convert inside templates
- 109 Parameter list
- 110 Deprecated options
- 111 TemplateData
- 112 See also
- 113 Units to convert
- 114 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 115 Adjective: a 10-mile distance
- 116 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 116.1 Default rounding
- 116.2 Round to a given precision: use a precision number
- 116.3 Round to a given number of significant figures: Template:Para
- 116.4 Round to a multiple of 5: 15, 20, 25, ...
- 116.5 Round to a multiple of a given fraction: Template:Frac inch
- 116.6 Template:AnchorRounding temperatures: °C, °F and K
- 116.7 Rounding input
- 117 Into multiple units: Template loop detected: Template:Convert
- 118 Ranges of values
- 119 Words
- 119.1 Spelling of unit name: international metre or US meter?
- 119.2 Spell out numbers: ten miles
- 119.3 Inserted before units: 4 planted acres
- 119.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 119.5 Plurals: 1 inch, 2 inches
- 119.6 Fractions: one-eighth of an imperial pint
- 119.7 Wrapping and line breaking
- 119.8 Spelling out "thousands", "millions", etc.
- 120 Numbers
- 120.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 120.2 Engineering notation: 7 × 106 m
- 120.3 Scientific notation: 1.23 × 10−14
- 120.4 Input with fractions: Template loop detected: Template:Convert
- 120.5 Horizontal fraction bar: Template:Sfrac inch
- 120.6 Thousands separator: 1,000 mi or 1000 mi
- 121 Output manipulation
- 121.1 Brackets and separators: 10 m [33 ft]
- 121.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 121.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 121.4 Displaying parts of the result: Template loop detected: Template:Convert
- 121.5 Display both input name and symbol: 2 kilopascals [kPa]
- 122 Table options
- 123 Units
- 124 Using convert inside templates
- 125 Parameter list
- 126 Deprecated options
- 127 TemplateData
- 128 See also
- 129 Units to convert
- 130 Units to convert
- 131 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 132 Adjective: a 10-mile distance
- 133 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 133.1 Default rounding
- 133.2 Round to a given precision: use a precision number
- 133.3 Round to a given number of significant figures: Template:Para
- 133.4 Round to a multiple of 5: 15, 20, 25, ...
- 133.5 Round to a multiple of a given fraction: Template:Frac inch
- 133.6 Template:AnchorRounding temperatures: °C, °F and K
- 133.7 Rounding input
- 134 Into multiple units: Template loop detected: Template:Convert
- 135 Ranges of values
- 136 Words
- 136.1 Spelling of unit name: international metre or US meter?
- 136.2 Spell out numbers: ten miles
- 136.3 Inserted before units: 4 planted acres
- 136.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 136.5 Plurals: 1 inch, 2 inches
- 136.6 Fractions: one-eighth of an imperial pint
- 136.7 Wrapping and line breaking
- 136.8 Spelling out "thousands", "millions", etc.
- 137 Numbers
- 137.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 137.2 Engineering notation: 7 × 106 m
- 137.3 Scientific notation: 1.23 × 10−14
- 137.4 Input with fractions: Template loop detected: Template:Convert
- 137.5 Horizontal fraction bar: Template:Sfrac inch
- 137.6 Thousands separator: 1,000 mi or 1000 mi
- 138 Output manipulation
- 138.1 Brackets and separators: 10 m [33 ft]
- 138.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 138.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 138.4 Displaying parts of the result: Template loop detected: Template:Convert
- 138.5 Display both input name and symbol: 2 kilopascals [kPa]
- 139 Table options
- 140 Units
- 141 Using convert inside templates
- 142 Parameter list
- 143 Deprecated options
- 144 TemplateData
- 145 See also
- 146 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 147 Units to convert
- 148 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 149 Adjective: a 10-mile distance
- 150 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 150.1 Default rounding
- 150.2 Round to a given precision: use a precision number
- 150.3 Round to a given number of significant figures: Template:Para
- 150.4 Round to a multiple of 5: 15, 20, 25, ...
- 150.5 Round to a multiple of a given fraction: Template:Frac inch
- 150.6 Template:AnchorRounding temperatures: °C, °F and K
- 150.7 Rounding input
- 151 Into multiple units: Template loop detected: Template:Convert
- 152 Ranges of values
- 153 Words
- 153.1 Spelling of unit name: international metre or US meter?
- 153.2 Spell out numbers: ten miles
- 153.3 Inserted before units: 4 planted acres
- 153.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 153.5 Plurals: 1 inch, 2 inches
- 153.6 Fractions: one-eighth of an imperial pint
- 153.7 Wrapping and line breaking
- 153.8 Spelling out "thousands", "millions", etc.
- 154 Numbers
- 154.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 154.2 Engineering notation: 7 × 106 m
- 154.3 Scientific notation: 1.23 × 10−14
- 154.4 Input with fractions: Template loop detected: Template:Convert
- 154.5 Horizontal fraction bar: Template:Sfrac inch
- 154.6 Thousands separator: 1,000 mi or 1000 mi
- 155 Output manipulation
- 155.1 Brackets and separators: 10 m [33 ft]
- 155.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 155.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 155.4 Displaying parts of the result: Template loop detected: Template:Convert
- 155.5 Display both input name and symbol: 2 kilopascals [kPa]
- 156 Table options
- 157 Units
- 158 Using convert inside templates
- 159 Parameter list
- 160 Deprecated options
- 161 TemplateData
- 162 See also
- 163 Units to convert
- 164 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 165 Adjective: a 10-mile distance
- 166 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 166.1 Default rounding
- 166.2 Round to a given precision: use a precision number
- 166.3 Round to a given number of significant figures: Template:Para
- 166.4 Round to a multiple of 5: 15, 20, 25, ...
- 166.5 Round to a multiple of a given fraction: Template:Frac inch
- 166.6 Template:AnchorRounding temperatures: °C, °F and K
- 166.7 Rounding input
- 167 Into multiple units: Template loop detected: Template:Convert
- 168 Ranges of values
- 169 Words
- 169.1 Spelling of unit name: international metre or US meter?
- 169.2 Spell out numbers: ten miles
- 169.3 Inserted before units: 4 planted acres
- 169.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 169.5 Plurals: 1 inch, 2 inches
- 169.6 Fractions: one-eighth of an imperial pint
- 169.7 Wrapping and line breaking
- 169.8 Spelling out "thousands", "millions", etc.
- 170 Numbers
- 170.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 170.2 Engineering notation: 7 × 106 m
- 170.3 Scientific notation: 1.23 × 10−14
- 170.4 Input with fractions: Template loop detected: Template:Convert
- 170.5 Horizontal fraction bar: Template:Sfrac inch
- 170.6 Thousands separator: 1,000 mi or 1000 mi
- 171 Output manipulation
- 171.1 Brackets and separators: 10 m [33 ft]
- 171.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 171.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 171.4 Displaying parts of the result: Template loop detected: Template:Convert
- 171.5 Display both input name and symbol: 2 kilopascals [kPa]
- 172 Table options
- 173 Units
- 174 Using convert inside templates
- 175 Parameter list
- 176 Deprecated options
- 177 TemplateData
- 178 See also
- 179 Units to convert
- 180 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 181 Adjective: a 10-mile distance
- 182 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 182.1 Default rounding
- 182.2 Round to a given precision: use a precision number
- 182.3 Round to a given number of significant figures: Template:Para
- 182.4 Round to a multiple of 5: 15, 20, 25, ...
- 182.5 Round to a multiple of a given fraction: Template:Frac inch
- 182.6 Template:AnchorRounding temperatures: °C, °F and K
- 182.7 Rounding input
- 183 Into multiple units: Template loop detected: Template:Convert
- 184 Ranges of values
- 185 Words
- 185.1 Spelling of unit name: international metre or US meter?
- 185.2 Spell out numbers: ten miles
- 185.3 Inserted before units: 4 planted acres
- 185.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 185.5 Plurals: 1 inch, 2 inches
- 185.6 Fractions: one-eighth of an imperial pint
- 185.7 Wrapping and line breaking
- 185.8 Spelling out "thousands", "millions", etc.
- 186 Numbers
- 186.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 186.2 Engineering notation: 7 × 106 m
- 186.3 Scientific notation: 1.23 × 10−14
- 186.4 Input with fractions: Template loop detected: Template:Convert
- 186.5 Horizontal fraction bar: Template:Sfrac inch
- 186.6 Thousands separator: 1,000 mi or 1000 mi
- 187 Output manipulation
- 187.1 Brackets and separators: 10 m [33 ft]
- 187.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 187.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 187.4 Displaying parts of the result: Template loop detected: Template:Convert
- 187.5 Display both input name and symbol: 2 kilopascals [kPa]
- 188 Table options
- 189 Units
- 190 Using convert inside templates
- 191 Parameter list
- 192 Deprecated options
- 193 TemplateData
- 194 See also
- 195 Units to convert
- 196 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 197 Adjective: a 10-mile distance
- 198 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 198.1 Default rounding
- 198.2 Round to a given precision: use a precision number
- 198.3 Round to a given number of significant figures: Template:Para
- 198.4 Round to a multiple of 5: 15, 20, 25, ...
- 198.5 Round to a multiple of a given fraction: Template:Frac inch
- 198.6 Template:AnchorRounding temperatures: °C, °F and K
- 198.7 Rounding input
- 199 Into multiple units: Template loop detected: Template:Convert
- 200 Ranges of values
- 201 Words
- 201.1 Spelling of unit name: international metre or US meter?
- 201.2 Spell out numbers: ten miles
- 201.3 Inserted before units: 4 planted acres
- 201.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 201.5 Plurals: 1 inch, 2 inches
- 201.6 Fractions: one-eighth of an imperial pint
- 201.7 Wrapping and line breaking
- 201.8 Spelling out "thousands", "millions", etc.
- 202 Numbers
- 202.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 202.2 Engineering notation: 7 × 106 m
- 202.3 Scientific notation: 1.23 × 10−14
- 202.4 Input with fractions: Template loop detected: Template:Convert
- 202.5 Horizontal fraction bar: Template:Sfrac inch
- 202.6 Thousands separator: 1,000 mi or 1000 mi
- 203 Output manipulation
- 203.1 Brackets and separators: 10 m [33 ft]
- 203.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 203.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 203.4 Displaying parts of the result: Template loop detected: Template:Convert
- 203.5 Display both input name and symbol: 2 kilopascals [kPa]
- 204 Table options
- 205 Units
- 206 Using convert inside templates
- 207 Parameter list
- 208 Deprecated options
- 209 TemplateData
- 210 See also
- 211 Adjective: a 10-mile distance
- 212 Units to convert
- 213 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 214 Adjective: a 10-mile distance
- 215 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 215.1 Default rounding
- 215.2 Round to a given precision: use a precision number
- 215.3 Round to a given number of significant figures: Template:Para
- 215.4 Round to a multiple of 5: 15, 20, 25, ...
- 215.5 Round to a multiple of a given fraction: Template:Frac inch
- 215.6 Template:AnchorRounding temperatures: °C, °F and K
- 215.7 Rounding input
- 216 Into multiple units: Template loop detected: Template:Convert
- 217 Ranges of values
- 218 Words
- 218.1 Spelling of unit name: international metre or US meter?
- 218.2 Spell out numbers: ten miles
- 218.3 Inserted before units: 4 planted acres
- 218.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 218.5 Plurals: 1 inch, 2 inches
- 218.6 Fractions: one-eighth of an imperial pint
- 218.7 Wrapping and line breaking
- 218.8 Spelling out "thousands", "millions", etc.
- 219 Numbers
- 219.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 219.2 Engineering notation: 7 × 106 m
- 219.3 Scientific notation: 1.23 × 10−14
- 219.4 Input with fractions: Template loop detected: Template:Convert
- 219.5 Horizontal fraction bar: Template:Sfrac inch
- 219.6 Thousands separator: 1,000 mi or 1000 mi
- 220 Output manipulation
- 220.1 Brackets and separators: 10 m [33 ft]
- 220.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 220.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 220.4 Displaying parts of the result: Template loop detected: Template:Convert
- 220.5 Display both input name and symbol: 2 kilopascals [kPa]
- 221 Table options
- 222 Units
- 223 Using convert inside templates
- 224 Parameter list
- 225 Deprecated options
- 226 TemplateData
- 227 See also
- 228 Units to convert
- 229 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 230 Adjective: a 10-mile distance
- 231 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 231.1 Default rounding
- 231.2 Round to a given precision: use a precision number
- 231.3 Round to a given number of significant figures: Template:Para
- 231.4 Round to a multiple of 5: 15, 20, 25, ...
- 231.5 Round to a multiple of a given fraction: Template:Frac inch
- 231.6 Template:AnchorRounding temperatures: °C, °F and K
- 231.7 Rounding input
- 232 Into multiple units: Template loop detected: Template:Convert
- 233 Ranges of values
- 234 Words
- 234.1 Spelling of unit name: international metre or US meter?
- 234.2 Spell out numbers: ten miles
- 234.3 Inserted before units: 4 planted acres
- 234.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 234.5 Plurals: 1 inch, 2 inches
- 234.6 Fractions: one-eighth of an imperial pint
- 234.7 Wrapping and line breaking
- 234.8 Spelling out "thousands", "millions", etc.
- 235 Numbers
- 235.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 235.2 Engineering notation: 7 × 106 m
- 235.3 Scientific notation: 1.23 × 10−14
- 235.4 Input with fractions: Template loop detected: Template:Convert
- 235.5 Horizontal fraction bar: Template:Sfrac inch
- 235.6 Thousands separator: 1,000 mi or 1000 mi
- 236 Output manipulation
- 236.1 Brackets and separators: 10 m [33 ft]
- 236.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 236.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 236.4 Displaying parts of the result: Template loop detected: Template:Convert
- 236.5 Display both input name and symbol: 2 kilopascals [kPa]
- 237 Table options
- 238 Units
- 239 Using convert inside templates
- 240 Parameter list
- 241 Deprecated options
- 242 TemplateData
- 243 See also
- 244 Units to convert
- 245 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 246 Adjective: a 10-mile distance
- 247 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 247.1 Default rounding
- 247.2 Round to a given precision: use a precision number
- 247.3 Round to a given number of significant figures: Template:Para
- 247.4 Round to a multiple of 5: 15, 20, 25, ...
- 247.5 Round to a multiple of a given fraction: Template:Frac inch
- 247.6 Template:AnchorRounding temperatures: °C, °F and K
- 247.7 Rounding input
- 248 Into multiple units: Template loop detected: Template:Convert
- 249 Ranges of values
- 250 Words
- 250.1 Spelling of unit name: international metre or US meter?
- 250.2 Spell out numbers: ten miles
- 250.3 Inserted before units: 4 planted acres
- 250.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 250.5 Plurals: 1 inch, 2 inches
- 250.6 Fractions: one-eighth of an imperial pint
- 250.7 Wrapping and line breaking
- 250.8 Spelling out "thousands", "millions", etc.
- 251 Numbers
- 251.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 251.2 Engineering notation: 7 × 106 m
- 251.3 Scientific notation: 1.23 × 10−14
- 251.4 Input with fractions: Template loop detected: Template:Convert
- 251.5 Horizontal fraction bar: Template:Sfrac inch
- 251.6 Thousands separator: 1,000 mi or 1000 mi
- 252 Output manipulation
- 252.1 Brackets and separators: 10 m [33 ft]
- 252.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 252.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 252.4 Displaying parts of the result: Template loop detected: Template:Convert
- 252.5 Display both input name and symbol: 2 kilopascals [kPa]
- 253 Table options
- 254 Units
- 255 Using convert inside templates
- 256 Parameter list
- 257 Deprecated options
- 258 TemplateData
- 259 See also
- 260 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 261 Units to convert
- 262 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 263 Adjective: a 10-mile distance
- 264 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 264.1 Default rounding
- 264.2 Round to a given precision: use a precision number
- 264.3 Round to a given number of significant figures: Template:Para
- 264.4 Round to a multiple of 5: 15, 20, 25, ...
- 264.5 Round to a multiple of a given fraction: Template:Frac inch
- 264.6 Template:AnchorRounding temperatures: °C, °F and K
- 264.7 Rounding input
- 265 Into multiple units: Template loop detected: Template:Convert
- 266 Ranges of values
- 267 Words
- 267.1 Spelling of unit name: international metre or US meter?
- 267.2 Spell out numbers: ten miles
- 267.3 Inserted before units: 4 planted acres
- 267.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 267.5 Plurals: 1 inch, 2 inches
- 267.6 Fractions: one-eighth of an imperial pint
- 267.7 Wrapping and line breaking
- 267.8 Spelling out "thousands", "millions", etc.
- 268 Numbers
- 268.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 268.2 Engineering notation: 7 × 106 m
- 268.3 Scientific notation: 1.23 × 10−14
- 268.4 Input with fractions: Template loop detected: Template:Convert
- 268.5 Horizontal fraction bar: Template:Sfrac inch
- 268.6 Thousands separator: 1,000 mi or 1000 mi
- 269 Output manipulation
- 269.1 Brackets and separators: 10 m [33 ft]
- 269.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 269.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 269.4 Displaying parts of the result: Template loop detected: Template:Convert
- 269.5 Display both input name and symbol: 2 kilopascals [kPa]
- 270 Table options
- 271 Units
- 272 Using convert inside templates
- 273 Parameter list
- 274 Deprecated options
- 275 TemplateData
- 276 See also
- 277 Units to convert
- 278 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 279 Adjective: a 10-mile distance
- 280 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 280.1 Default rounding
- 280.2 Round to a given precision: use a precision number
- 280.3 Round to a given number of significant figures: Template:Para
- 280.4 Round to a multiple of 5: 15, 20, 25, ...
- 280.5 Round to a multiple of a given fraction: Template:Frac inch
- 280.6 Template:AnchorRounding temperatures: °C, °F and K
- 280.7 Rounding input
- 281 Into multiple units: Template loop detected: Template:Convert
- 282 Ranges of values
- 283 Words
- 283.1 Spelling of unit name: international metre or US meter?
- 283.2 Spell out numbers: ten miles
- 283.3 Inserted before units: 4 planted acres
- 283.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 283.5 Plurals: 1 inch, 2 inches
- 283.6 Fractions: one-eighth of an imperial pint
- 283.7 Wrapping and line breaking
- 283.8 Spelling out "thousands", "millions", etc.
- 284 Numbers
- 284.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 284.2 Engineering notation: 7 × 106 m
- 284.3 Scientific notation: 1.23 × 10−14
- 284.4 Input with fractions: Template loop detected: Template:Convert
- 284.5 Horizontal fraction bar: Template:Sfrac inch
- 284.6 Thousands separator: 1,000 mi or 1000 mi
- 285 Output manipulation
- 285.1 Brackets and separators: 10 m [33 ft]
- 285.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 285.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 285.4 Displaying parts of the result: Template loop detected: Template:Convert
- 285.5 Display both input name and symbol: 2 kilopascals [kPa]
- 286 Table options
- 287 Units
- 288 Using convert inside templates
- 289 Parameter list
- 290 Deprecated options
- 291 TemplateData
- 292 See also
- 293 Units to convert
- 294 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 295 Adjective: a 10-mile distance
- 296 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 296.1 Default rounding
- 296.2 Round to a given precision: use a precision number
- 296.3 Round to a given number of significant figures: Template:Para
- 296.4 Round to a multiple of 5: 15, 20, 25, ...
- 296.5 Round to a multiple of a given fraction: Template:Frac inch
- 296.6 Template:AnchorRounding temperatures: °C, °F and K
- 296.7 Rounding input
- 297 Into multiple units: Template loop detected: Template:Convert
- 298 Ranges of values
- 299 Words
- 299.1 Spelling of unit name: international metre or US meter?
- 299.2 Spell out numbers: ten miles
- 299.3 Inserted before units: 4 planted acres
- 299.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 299.5 Plurals: 1 inch, 2 inches
- 299.6 Fractions: one-eighth of an imperial pint
- 299.7 Wrapping and line breaking
- 299.8 Spelling out "thousands", "millions", etc.
- 300 Numbers
- 300.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 300.2 Engineering notation: 7 × 106 m
- 300.3 Scientific notation: 1.23 × 10−14
- 300.4 Input with fractions: Template loop detected: Template:Convert
- 300.5 Horizontal fraction bar: Template:Sfrac inch
- 300.6 Thousands separator: 1,000 mi or 1000 mi
- 301 Output manipulation
- 301.1 Brackets and separators: 10 m [33 ft]
- 301.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 301.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 301.4 Displaying parts of the result: Template loop detected: Template:Convert
- 301.5 Display both input name and symbol: 2 kilopascals [kPa]
- 302 Table options
- 303 Units
- 304 Using convert inside templates
- 305 Parameter list
- 306 Deprecated options
- 307 TemplateData
- 308 See also
- 309 Units to convert
- 310 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 311 Adjective: a 10-mile distance
- 312 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 312.1 Default rounding
- 312.2 Round to a given precision: use a precision number
- 312.3 Round to a given number of significant figures: Template:Para
- 312.4 Round to a multiple of 5: 15, 20, 25, ...
- 312.5 Round to a multiple of a given fraction: Template:Frac inch
- 312.6 Template:AnchorRounding temperatures: °C, °F and K
- 312.7 Rounding input
- 313 Into multiple units: Template loop detected: Template:Convert
- 314 Ranges of values
- 315 Words
- 315.1 Spelling of unit name: international metre or US meter?
- 315.2 Spell out numbers: ten miles
- 315.3 Inserted before units: 4 planted acres
- 315.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 315.5 Plurals: 1 inch, 2 inches
- 315.6 Fractions: one-eighth of an imperial pint
- 315.7 Wrapping and line breaking
- 315.8 Spelling out "thousands", "millions", etc.
- 316 Numbers
- 316.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 316.2 Engineering notation: 7 × 106 m
- 316.3 Scientific notation: 1.23 × 10−14
- 316.4 Input with fractions: Template loop detected: Template:Convert
- 316.5 Horizontal fraction bar: Template:Sfrac inch
- 316.6 Thousands separator: 1,000 mi or 1000 mi
- 317 Output manipulation
- 317.1 Brackets and separators: 10 m [33 ft]
- 317.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 317.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 317.4 Displaying parts of the result: Template loop detected: Template:Convert
- 317.5 Display both input name and symbol: 2 kilopascals [kPa]
- 318 Table options
- 319 Units
- 320 Using convert inside templates
- 321 Parameter list
- 322 Deprecated options
- 323 TemplateData
- 324 See also
- 325 Units to convert
- 326 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 327 Adjective: a 10-mile distance
- 328 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 328.1 Default rounding
- 328.2 Round to a given precision: use a precision number
- 328.3 Round to a given number of significant figures: Template:Para
- 328.4 Round to a multiple of 5: 15, 20, 25, ...
- 328.5 Round to a multiple of a given fraction: Template:Frac inch
- 328.6 Template:AnchorRounding temperatures: °C, °F and K
- 328.7 Rounding input
- 329 Into multiple units: Template loop detected: Template:Convert
- 330 Ranges of values
- 331 Words
- 331.1 Spelling of unit name: international metre or US meter?
- 331.2 Spell out numbers: ten miles
- 331.3 Inserted before units: 4 planted acres
- 331.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 331.5 Plurals: 1 inch, 2 inches
- 331.6 Fractions: one-eighth of an imperial pint
- 331.7 Wrapping and line breaking
- 331.8 Spelling out "thousands", "millions", etc.
- 332 Numbers
- 332.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 332.2 Engineering notation: 7 × 106 m
- 332.3 Scientific notation: 1.23 × 10−14
- 332.4 Input with fractions: Template loop detected: Template:Convert
- 332.5 Horizontal fraction bar: Template:Sfrac inch
- 332.6 Thousands separator: 1,000 mi or 1000 mi
- 333 Output manipulation
- 333.1 Brackets and separators: 10 m [33 ft]
- 333.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 333.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 333.4 Displaying parts of the result: Template loop detected: Template:Convert
- 333.5 Display both input name and symbol: 2 kilopascals [kPa]
- 334 Table options
- 335 Units
- 336 Using convert inside templates
- 337 Parameter list
- 338 Deprecated options
- 339 TemplateData
- 340 See also
- 341 Units to convert
- 342 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 343 Adjective: a 10-mile distance
- 344 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 344.1 Default rounding
- 344.2 Round to a given precision: use a precision number
- 344.3 Round to a given number of significant figures: Template:Para
- 344.4 Round to a multiple of 5: 15, 20, 25, ...
- 344.5 Round to a multiple of a given fraction: Template:Frac inch
- 344.6 Template:AnchorRounding temperatures: °C, °F and K
- 344.7 Rounding input
- 345 Into multiple units: Template loop detected: Template:Convert
- 346 Ranges of values
- 347 Words
- 347.1 Spelling of unit name: international metre or US meter?
- 347.2 Spell out numbers: ten miles
- 347.3 Inserted before units: 4 planted acres
- 347.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 347.5 Plurals: 1 inch, 2 inches
- 347.6 Fractions: one-eighth of an imperial pint
- 347.7 Wrapping and line breaking
- 347.8 Spelling out "thousands", "millions", etc.
- 348 Numbers
- 348.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 348.2 Engineering notation: 7 × 106 m
- 348.3 Scientific notation: 1.23 × 10−14
- 348.4 Input with fractions: Template loop detected: Template:Convert
- 348.5 Horizontal fraction bar: Template:Sfrac inch
- 348.6 Thousands separator: 1,000 mi or 1000 mi
- 349 Output manipulation
- 349.1 Brackets and separators: 10 m [33 ft]
- 349.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 349.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 349.4 Displaying parts of the result: Template loop detected: Template:Convert
- 349.5 Display both input name and symbol: 2 kilopascals [kPa]
- 350 Table options
- 351 Units
- 352 Using convert inside templates
- 353 Parameter list
- 354 Deprecated options
- 355 TemplateData
- 356 See also
- 357 Units to convert
- 358 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 359 Adjective: a 10-mile distance
- 360 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 360.1 Default rounding
- 360.2 Round to a given precision: use a precision number
- 360.3 Round to a given number of significant figures: Template:Para
- 360.4 Round to a multiple of 5: 15, 20, 25, ...
- 360.5 Round to a multiple of a given fraction: Template:Frac inch
- 360.6 Template:AnchorRounding temperatures: °C, °F and K
- 360.7 Rounding input
- 361 Into multiple units: Template loop detected: Template:Convert
- 362 Ranges of values
- 363 Words
- 363.1 Spelling of unit name: international metre or US meter?
- 363.2 Spell out numbers: ten miles
- 363.3 Inserted before units: 4 planted acres
- 363.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 363.5 Plurals: 1 inch, 2 inches
- 363.6 Fractions: one-eighth of an imperial pint
- 363.7 Wrapping and line breaking
- 363.8 Spelling out "thousands", "millions", etc.
- 364 Numbers
- 364.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 364.2 Engineering notation: 7 × 106 m
- 364.3 Scientific notation: 1.23 × 10−14
- 364.4 Input with fractions: Template loop detected: Template:Convert
- 364.5 Horizontal fraction bar: Template:Sfrac inch
- 364.6 Thousands separator: 1,000 mi or 1000 mi
- 365 Output manipulation
- 365.1 Brackets and separators: 10 m [33 ft]
- 365.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 365.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 365.4 Displaying parts of the result: Template loop detected: Template:Convert
- 365.5 Display both input name and symbol: 2 kilopascals [kPa]
- 366 Table options
- 367 Units
- 368 Using convert inside templates
- 369 Parameter list
- 370 Deprecated options
- 371 TemplateData
- 372 See also
- 373 Units to convert
- 374 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 375 Adjective: a 10-mile distance
- 376 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 376.1 Default rounding
- 376.2 Round to a given precision: use a precision number
- 376.3 Round to a given number of significant figures: Template:Para
- 376.4 Round to a multiple of 5: 15, 20, 25, ...
- 376.5 Round to a multiple of a given fraction: Template:Frac inch
- 376.6 Template:AnchorRounding temperatures: °C, °F and K
- 376.7 Rounding input
- 377 Into multiple units: Template loop detected: Template:Convert
- 378 Ranges of values
- 379 Words
- 379.1 Spelling of unit name: international metre or US meter?
- 379.2 Spell out numbers: ten miles
- 379.3 Inserted before units: 4 planted acres
- 379.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 379.5 Plurals: 1 inch, 2 inches
- 379.6 Fractions: one-eighth of an imperial pint
- 379.7 Wrapping and line breaking
- 379.8 Spelling out "thousands", "millions", etc.
- 380 Numbers
- 380.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 380.2 Engineering notation: 7 × 106 m
- 380.3 Scientific notation: 1.23 × 10−14
- 380.4 Input with fractions: Template loop detected: Template:Convert
- 380.5 Horizontal fraction bar: Template:Sfrac inch
- 380.6 Thousands separator: 1,000 mi or 1000 mi
- 381 Output manipulation
- 381.1 Brackets and separators: 10 m [33 ft]
- 381.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 381.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 381.4 Displaying parts of the result: Template loop detected: Template:Convert
- 381.5 Display both input name and symbol: 2 kilopascals [kPa]
- 382 Table options
- 383 Units
- 384 Using convert inside templates
- 385 Parameter list
- 386 Deprecated options
- 387 TemplateData
- 388 See also
- 389 Units to convert
- 390 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 391 Adjective: a 10-mile distance
- 392 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 392.1 Default rounding
- 392.2 Round to a given precision: use a precision number
- 392.3 Round to a given number of significant figures: Template:Para
- 392.4 Round to a multiple of 5: 15, 20, 25, ...
- 392.5 Round to a multiple of a given fraction: Template:Frac inch
- 392.6 Template:AnchorRounding temperatures: °C, °F and K
- 392.7 Rounding input
- 393 Into multiple units: Template loop detected: Template:Convert
- 394 Ranges of values
- 395 Words
- 395.1 Spelling of unit name: international metre or US meter?
- 395.2 Spell out numbers: ten miles
- 395.3 Inserted before units: 4 planted acres
- 395.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 395.5 Plurals: 1 inch, 2 inches
- 395.6 Fractions: one-eighth of an imperial pint
- 395.7 Wrapping and line breaking
- 395.8 Spelling out "thousands", "millions", etc.
- 396 Numbers
- 396.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 396.2 Engineering notation: 7 × 106 m
- 396.3 Scientific notation: 1.23 × 10−14
- 396.4 Input with fractions: Template loop detected: Template:Convert
- 396.5 Horizontal fraction bar: Template:Sfrac inch
- 396.6 Thousands separator: 1,000 mi or 1000 mi
- 397 Output manipulation
- 397.1 Brackets and separators: 10 m [33 ft]
- 397.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 397.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 397.4 Displaying parts of the result: Template loop detected: Template:Convert
- 397.5 Display both input name and symbol: 2 kilopascals [kPa]
- 398 Table options
- 399 Units
- 400 Using convert inside templates
- 401 Parameter list
- 402 Deprecated options
- 403 TemplateData
- 404 See also
- 405 Units to convert
- 406 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 407 Adjective: a 10-mile distance
- 408 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 408.1 Default rounding
- 408.2 Round to a given precision: use a precision number
- 408.3 Round to a given number of significant figures: Template:Para
- 408.4 Round to a multiple of 5: 15, 20, 25, ...
- 408.5 Round to a multiple of a given fraction: Template:Frac inch
- 408.6 Template:AnchorRounding temperatures: °C, °F and K
- 408.7 Rounding input
- 409 Into multiple units: Template loop detected: Template:Convert
- 410 Ranges of values
- 411 Words
- 411.1 Spelling of unit name: international metre or US meter?
- 411.2 Spell out numbers: ten miles
- 411.3 Inserted before units: 4 planted acres
- 411.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 411.5 Plurals: 1 inch, 2 inches
- 411.6 Fractions: one-eighth of an imperial pint
- 411.7 Wrapping and line breaking
- 411.8 Spelling out "thousands", "millions", etc.
- 412 Numbers
- 412.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 412.2 Engineering notation: 7 × 106 m
- 412.3 Scientific notation: 1.23 × 10−14
- 412.4 Input with fractions: Template loop detected: Template:Convert
- 412.5 Horizontal fraction bar: Template:Sfrac inch
- 412.6 Thousands separator: 1,000 mi or 1000 mi
- 413 Output manipulation
- 413.1 Brackets and separators: 10 m [33 ft]
- 413.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 413.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 413.4 Displaying parts of the result: Template loop detected: Template:Convert
- 413.5 Display both input name and symbol: 2 kilopascals [kPa]
- 414 Table options
- 415 Units
- 416 Using convert inside templates
- 417 Parameter list
- 418 Deprecated options
- 419 TemplateData
- 420 See also
- 421 Units to convert
- 422 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 423 Adjective: a 10-mile distance
- 424 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 424.1 Default rounding
- 424.2 Round to a given precision: use a precision number
- 424.3 Round to a given number of significant figures: Template:Para
- 424.4 Round to a multiple of 5: 15, 20, 25, ...
- 424.5 Round to a multiple of a given fraction: Template:Frac inch
- 424.6 Template:AnchorRounding temperatures: °C, °F and K
- 424.7 Rounding input
- 425 Into multiple units: Template loop detected: Template:Convert
- 426 Ranges of values
- 427 Words
- 427.1 Spelling of unit name: international metre or US meter?
- 427.2 Spell out numbers: ten miles
- 427.3 Inserted before units: 4 planted acres
- 427.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 427.5 Plurals: 1 inch, 2 inches
- 427.6 Fractions: one-eighth of an imperial pint
- 427.7 Wrapping and line breaking
- 427.8 Spelling out "thousands", "millions", etc.
- 428 Numbers
- 428.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 428.2 Engineering notation: 7 × 106 m
- 428.3 Scientific notation: 1.23 × 10−14
- 428.4 Input with fractions: Template loop detected: Template:Convert
- 428.5 Horizontal fraction bar: Template:Sfrac inch
- 428.6 Thousands separator: 1,000 mi or 1000 mi
- 429 Output manipulation
- 429.1 Brackets and separators: 10 m [33 ft]
- 429.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 429.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 429.4 Displaying parts of the result: Template loop detected: Template:Convert
- 429.5 Display both input name and symbol: 2 kilopascals [kPa]
- 430 Table options
- 431 Units
- 432 Using convert inside templates
- 433 Parameter list
- 434 Deprecated options
- 435 TemplateData
- 436 See also
- 437 Units to convert
- 438 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 439 Adjective: a 10-mile distance
- 440 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 440.1 Default rounding
- 440.2 Round to a given precision: use a precision number
- 440.3 Round to a given number of significant figures: Template:Para
- 440.4 Round to a multiple of 5: 15, 20, 25, ...
- 440.5 Round to a multiple of a given fraction: Template:Frac inch
- 440.6 Template:AnchorRounding temperatures: °C, °F and K
- 440.7 Rounding input
- 441 Into multiple units: Template loop detected: Template:Convert
- 442 Ranges of values
- 443 Words
- 443.1 Spelling of unit name: international metre or US meter?
- 443.2 Spell out numbers: ten miles
- 443.3 Inserted before units: 4 planted acres
- 443.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 443.5 Plurals: 1 inch, 2 inches
- 443.6 Fractions: one-eighth of an imperial pint
- 443.7 Wrapping and line breaking
- 443.8 Spelling out "thousands", "millions", etc.
- 444 Numbers
- 444.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 444.2 Engineering notation: 7 × 106 m
- 444.3 Scientific notation: 1.23 × 10−14
- 444.4 Input with fractions: Template loop detected: Template:Convert
- 444.5 Horizontal fraction bar: Template:Sfrac inch
- 444.6 Thousands separator: 1,000 mi or 1000 mi
- 445 Output manipulation
- 445.1 Brackets and separators: 10 m [33 ft]
- 445.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 445.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 445.4 Displaying parts of the result: Template loop detected: Template:Convert
- 445.5 Display both input name and symbol: 2 kilopascals [kPa]
- 446 Table options
- 447 Units
- 448 Using convert inside templates
- 449 Parameter list
- 450 Deprecated options
- 451 TemplateData
- 452 See also
- 453 Units to convert
- 454 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 455 Adjective: a 10-mile distance
- 456 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 456.1 Default rounding
- 456.2 Round to a given precision: use a precision number
- 456.3 Round to a given number of significant figures: Template:Para
- 456.4 Round to a multiple of 5: 15, 20, 25, ...
- 456.5 Round to a multiple of a given fraction: Template:Frac inch
- 456.6 Template:AnchorRounding temperatures: °C, °F and K
- 456.7 Rounding input
- 457 Into multiple units: Template loop detected: Template:Convert
- 458 Ranges of values
- 459 Words
- 459.1 Spelling of unit name: international metre or US meter?
- 459.2 Spell out numbers: ten miles
- 459.3 Inserted before units: 4 planted acres
- 459.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 459.5 Plurals: 1 inch, 2 inches
- 459.6 Fractions: one-eighth of an imperial pint
- 459.7 Wrapping and line breaking
- 459.8 Spelling out "thousands", "millions", etc.
- 460 Numbers
- 460.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 460.2 Engineering notation: 7 × 106 m
- 460.3 Scientific notation: 1.23 × 10−14
- 460.4 Input with fractions: Template loop detected: Template:Convert
- 460.5 Horizontal fraction bar: Template:Sfrac inch
- 460.6 Thousands separator: 1,000 mi or 1000 mi
- 461 Output manipulation
- 461.1 Brackets and separators: 10 m [33 ft]
- 461.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 461.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 461.4 Displaying parts of the result: Template loop detected: Template:Convert
- 461.5 Display both input name and symbol: 2 kilopascals [kPa]
- 462 Table options
- 463 Units
- 464 Using convert inside templates
- 465 Parameter list
- 466 Deprecated options
- 467 TemplateData
- 468 See also
- 469 Units to convert
- 470 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 471 Adjective: a 10-mile distance
- 472 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 472.1 Default rounding
- 472.2 Round to a given precision: use a precision number
- 472.3 Round to a given number of significant figures: Template:Para
- 472.4 Round to a multiple of 5: 15, 20, 25, ...
- 472.5 Round to a multiple of a given fraction: Template:Frac inch
- 472.6 Template:AnchorRounding temperatures: °C, °F and K
- 472.7 Rounding input
- 473 Into multiple units: Template loop detected: Template:Convert
- 474 Ranges of values
- 475 Words
- 475.1 Spelling of unit name: international metre or US meter?
- 475.2 Spell out numbers: ten miles
- 475.3 Inserted before units: 4 planted acres
- 475.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 475.5 Plurals: 1 inch, 2 inches
- 475.6 Fractions: one-eighth of an imperial pint
- 475.7 Wrapping and line breaking
- 475.8 Spelling out "thousands", "millions", etc.
- 476 Numbers
- 476.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 476.2 Engineering notation: 7 × 106 m
- 476.3 Scientific notation: 1.23 × 10−14
- 476.4 Input with fractions: Template loop detected: Template:Convert
- 476.5 Horizontal fraction bar: Template:Sfrac inch
- 476.6 Thousands separator: 1,000 mi or 1000 mi
- 477 Output manipulation
- 477.1 Brackets and separators: 10 m [33 ft]
- 477.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 477.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 477.4 Displaying parts of the result: Template loop detected: Template:Convert
- 477.5 Display both input name and symbol: 2 kilopascals [kPa]
- 478 Table options
- 479 Units
- 480 Using convert inside templates
- 481 Parameter list
- 482 Deprecated options
- 483 TemplateData
- 484 See also
- 485 Units to convert
- 486 Unit name or symbol (abbreviation): 1 pound or 1 lb?
- 487 Adjective: a 10-mile distance
- 488 Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
- 488.1 Default rounding
- 488.2 Round to a given precision: use a precision number
- 488.3 Round to a given number of significant figures: Template:Para
- 488.4 Round to a multiple of 5: 15, 20, 25, ...
- 488.5 Round to a multiple of a given fraction: Template:Frac inch
- 488.6 Template:AnchorRounding temperatures: °C, °F and K
- 488.7 Rounding input
- 489 Into multiple units: Template loop detected: Template:Convert
- 490 Ranges of values
- 491 Words
- 491.1 Spelling of unit name: international metre or US meter?
- 491.2 Spell out numbers: ten miles
- 491.3 Inserted before units: 4 planted acres
- 491.4 After adjective unit: A Template loop detected: Template:Convert corridor
- 491.5 Plurals: 1 inch, 2 inches
- 491.6 Fractions: one-eighth of an imperial pint
- 491.7 Wrapping and line breaking
- 491.8 Spelling out "thousands", "millions", etc.
- 492 Numbers
- 492.1 Using an SI prefix: gigametre (Gm), or micrometre (μm)
- 492.2 Engineering notation: 7 × 106 m
- 492.3 Scientific notation: 1.23 × 10−14
- 492.4 Input with fractions: Template loop detected: Template:Convert
- 492.5 Horizontal fraction bar: Template:Sfrac inch
- 492.6 Thousands separator: 1,000 mi or 1000 mi
- 493 Output manipulation
- 493.1 Brackets and separators: 10 m [33 ft]
- 493.2 Flipping (reordering) the two measurements: Template loop detected: Template:Convert
- 493.3 Fixed ordering of output units: Template loop detected: Template:Convert
- 493.4 Displaying parts of the result: Template loop detected: Template:Convert
- 493.5 Display both input name and symbol: 2 kilopascals [kPa]
- 494 Table options
- 495 Units
- 496 Using convert inside templates
- 497 Parameter list
- 498 Deprecated options
- 499 TemplateData
- 500 See also
- 501 Into multiple units: Template:Convert
- 502 Ranges of values
- 503 Words
- 503.1 Spelling of unit name: international metre or US meter?
- 503.2 Spell out numbers: ten miles
- 503.3 Inserted before units: 4 planted acres
- 503.4 After adjective unit: A Template:Convert corridor
- 503.5 Plurals: 1 inch, 2 inches
- 503.6 Fractions: one-eighth of an imperial pint
- 503.7 Wrapping and line breaking
- 503.8 Spelling out "thousands", "millions", etc.
- 504 Numbers
- 505 Output manipulation
- 506 Table options
- 507 Units
- 508 Using convert inside templates
- 509 Parameter list
- 510 Deprecated options
- 511 TemplateData
- 512 See also
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other (km entered, so converted into mile)
{{convert|7|mi|km}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
{{convert|7|mi|km|2|abbr=on}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs
Template:Sandbox other
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
{{convert|2|-|5|km|mi}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
{{convert|1|lb|kg|abbr=off}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other distance. Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template:Documentation subpage Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|123|ft|m}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
Template:Convert navs Template:Sandbox other || same output as with 0 (below) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|123|ft|m|0}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|123|ft|m|1}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|123|ft|m|2}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
Template:Convert navs Template:Sandbox other ||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}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|500|ft|m}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
Template:Convert navs Template:Sandbox other || 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}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|500|ft|m|1}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|500|ft|m|2}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
Template:Convert navs Template:Sandbox other || exact value is 152.4 m | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|500|ft|cm|-3}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{convert|500|ft|cm}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
Template:Convert navs Template:Sandbox other || 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}} |
Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data. For example:
Numbers can be rounded, units can be abbreviated into symbols:
Value ranges can be entered using
Combined effect example:
Units to convertTemplate:Hatnote Enter units to convert from into:
Unit name or symbol (abbreviation): 1 pound or 1 lb?By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
Using Template:Para is the reverse behaviour to the default:
To abbreviate both or neither:
Convenience: Template:Tlf has Template:Para by defaultTemplate Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
is equivalent to:
Adjective: a 10-mile distanceUse Template:Para to produce the adjectival (hyphenated) form:
Default behaviour, for comparison:
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. Default roundingBy Template:Tlf 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).
Convert supports four types of rounding: Round to a given precision: use a precision numberSpecify 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 Template:Frac 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: Template:ParaTo specify the output number to be with n significant figures use Template:Para:
Default behaviour, for comparison:
Setting Template:Para to a value less than 1 is meaningless:
Round to a multiple of 5: 15, 20, 25, ...Using Template:Para rounds the outcome to a multiple of 5.
Similar: using Template:Para rounds the outcome to a multiple of 25.
Default behaviour, for comparison:
In a range, one can round each value individually to the default. Use Template:Para:
Round to a multiple of a given fraction: Template:Frac inchSpecify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
The fraction is reduced when possible:
Default behaviour uses decimal notation:
Template:AnchorRounding temperatures: °C, °F and KIn 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.
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 Template loop detected: Template:Convert, 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 Template:Para:
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
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 inputThere 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 Template:Tlc 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: Note that there is no Template:ParaTemplate:Nay 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:
In this case, if the input were rounded before conversion, a different result would be obtained:
Into multiple units: Template loop detected: Template:ConvertSeparate the multiple output units by a space:
If the output unit names contain spaces, use See also:
Ranges of valuesTemplate:For 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)Range indicators are entered as the second parameter (between the values). Range separators can be: Multiple dimensions: Template loop detected: Template:ConvertUse
Use
In science, the formal way is to set
Lists of values: 20, 40, or 60 miles
About feet, inch in ranges and multiplesWhile it is possible to enter feet, inch in a simple conversion, this is not possible for ranges:
Default behaviour, for comparison:
However, converting metric units into feet and inches with Template:Para can produce the desired output:
WordsSpelling of unit name: international metre or US meter?Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
Spell out numbers: ten milesTo write a number in words, use Template:Para:
To spell out both in and out values, use Template:Para:
To make first letter a capital, use Template:Para, Template:Para
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
Inserted before units: 4 planted acres
After adjective unit: A Template loop detected: Template:Convert corridorNote that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
Plurals: 1 inch, 2 inchesThe unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
Entering the unit spelled
Fractions: one-eighth of an imperial pintThe convert template also supports spelling out fractions.
Any additional words needed for the fraction can also be added at the end of the template.
Wrapping and line breakingSpelling out "thousands", "millions", etc.Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
To display both input and output in scientific notation, use Template:Para
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
NumbersUsing an SI prefix: gigametre (Gm), or micrometre (μm)Template:Sidebar metric prefixes (small)
Units can have an SI prefix like To illustrate, these are trivial calculations (from metre to metre), showing the multiplication factor:
The prefix can be added before the SI unit (here: unit
The prefix can be used in the output unit:
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
Engineering notation: 7 × 106 mIn the unit: e6mEngineering notation can be entered as a "prefix" to the unit:
The same is possible for the output unit:
Any standard unit (not a combination, multiple, or built-in unit) can have such a prefix:
Scientific notation: 1.23 × 10−14In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point. With Template:Tlf, the input can be in e-notation such as
Input with fractions: Template loop detected: Template:ConvertThe number to convert can be written in fractions. Both
With positive mixed numbers (a positive integer and a fraction), use a
With negative mixed numbers, use a hyphen
Note that the following cases are not interpreted as mixed numbers:
Horizontal fraction bar: Template:Sfrac inchUsing a double slash (
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
Thousands separator: 1,000 mi or 1000 miIn 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:
Set Template:Para to remove the separator from the output:
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
Default behaviour, for comparison:
Setting Template:Para will only add the separator when the number of digits is 5 or more:
Default behaviour, for comparison:
Output manipulationBrackets and separators: 10 m [33 ft]Punctuation that distinguishes the two measurements is set by Template:Para.
Default behaviour, for comparison:
Setting Template:Para will force a new line (
Also Template:Para will force a new line, and keep the brackets (useful in tables):
Setting Template:Para allows any text as separator:
Flipping (reordering) the two measurements: Template loop detected: Template:ConvertSetting Template:Para will flip (swap) the two measurements:
Default behaviour, for comparison:
When converting to multiple units, the effect is:
Fixed ordering of output units: Template loop detected: Template:ConvertSetting Template:Para shows the output-units as ordered; the input unit is skipped:
See also: § Displaying parts of the output. Displaying parts of the result: Template loop detected: Template:ConvertIt is possible to display only parts of the conversion result:
Display both input name and symbol: 2 kilopascals [kPa]Setting Template:Para returns both name and symbol of the first (input) unit:
Table optionsFor the wikitable structure, there are three options: add a line-break, split the result over columns and make the table sortable. Enforced line breakTemplate:Para adds a line-break and omits brackets. Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Table columnsUsing {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like
Template:Para does the same, and also centers the text:
The units are added as a column header:
SortingUse Template:Para 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:
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
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. UnitsThe conversion factors and physical constants are sourced here. All unitsTemplate:Selfref Template:Hatnote Template:Convert/list of units Template:Anchor'per' units: kg/hl, miles per gallonWhen using a slash (
Population density (inhabitants per square mile) can be converted using
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
Template:AnchorUnits of difference: Expressing a change or difference in temperatureWe have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para. Compare the following two examples with the two above:
To produce multiple units in the output:
Multiple units: 1 ft 5 inIn inputBase document Template:Slink lists options for multiple unit input (like
In outputAvailable multiple-unit output options predefined, like
Default behaviour, for comparison:
See also:
Currency per unit: $/mi → $/kmUsing currency symbols in a $ per unit value, you can convert the per-unit:
You can set the currency in both values using Template:Para:
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay Using convert inside templatesFor usage in template code, like infoboxes, Template:Tlf has these options:
Note: to return that property value for an other article, use Template:Para. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use. Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
Parameter listTemplate:Convert/doc/parameter list Deprecated optionsTemplate:Convert/doc/deprecations list TemplateData<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata> See also
|
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template:Documentation subpage
Template:Hatnote {{#ifeq:Template:Convert|Template:Convert|Template:High-risk}} Template:Transwiki guide Template:Lua Template Template:Tl 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 at Module:Convert/documentation/conversion data.
For example:
{{convert|2|km|mi}}
→ Template loop detected: Template:Convert (km entered, so converted into mile){{convert|7|mi|km}}
→ Template loop detected: Template:Convert (mi entered, so converted into km)
Numbers can be rounded, units can be abbreviated into symbols:
{{convert|2|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|7|mi|km|2|abbr=on}}
→ Template loop detected: Template:Convert
Value ranges can be entered using |to|...
or |-|...
:
{{convert|2|to|5|km|mi}}
→ Template loop detected: Template:Convert{{convert|2|-|5|km|mi}}
→ Template loop detected: Template:Convert
Combined effect example:
{{convert|2|-|5|km|mi|2|abbr=on}}
→ Template loop detected: Template:Convert{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
→ Template loop detected: Template:Convert
Units to convert
Template:Hatnote Enter units to convert from into:
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
- 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 Template:Cl
Unit name or symbol (abbreviation): 1 pound or 1 lb?
By default, the first quantity shows the unit name, the second shows the symbol (or abbreviation):
{{convert|1|lb|kg}}
→ Template loop detected: Template:Convert
Using Template:Para is the reverse behaviour to the default:
{{convert|1|lb|kg|abbr=in}}
→ Template loop detected: Template:Convert
To abbreviate both or neither:
{{convert|1|lb|kg|abbr=on}}
→ Template loop detected: Template:Convert{{convert|1|lb|kg|abbr=off}}
→ Template loop detected: Template:Convert
Convenience: Template:Tlf has Template:Para by default
Template Template:Tl is the same as Template:Tlf, except that it has Template:Para as the default behaviour. In Template:Tlf, all other options are available. So:
{{cvt|1|lb|kg}}
→ Template:Cvt
is equivalent to:
{{convert|1|lb|kg|abbr=on}}
→ Template:Cvt
Adjective: a 10-mile distance
Use Template:Para to produce the adjectival (hyphenated) form:
A {{convert|10|mi|km|adj=on}} distance
→ A Template loop detected: Template:Convert distance.
Default behaviour, for comparison:
{{convert|10|mi|km}} to go
→ Template loop detected: Template:Convert to go.
Template:Para does not produce hyphens with unit symbols, as per Manual of Style:
A {{convert|9|in|cm|adj=on|abbr=on}} nail
→ A Template loop detected: Template:Convert nail.
Template:AnchorRounding: 100 ft is 30 m or 30.5 m or 30.48 m?
Template:Hatnote By definition, 100 ft equals Template loop detected: Template:Convert. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
Default rounding
By Template:Tlf 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}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m}} |
Template loop detected: Template:Convert | same output as with 0 (below) |
{{convert|123|ft|m|0}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|123|ft|m|2}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|1}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|m|2}} |
Template loop detected: Template:Convert | exact value is 152.4 m |
{{convert|500|ft|cm|-3}} |
Template loop detected: Template:Convert | |
{{convert|500|ft|cm}} |
Template loop detected: Template:Convert | 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}} |
Template loop detected: Template:Convert |
Convert supports four types of rounding:
Round to a given precision: use a precision number
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 Template:Frac 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: Template:Para
To specify the output number to be with n significant figures use Template:Para:
{{convert|1200|ft|m|sigfig=4}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=3}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template loop detected: Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template loop detected: Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template loop detected: Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=5}}
→ Template loop detected: Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|round=25}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template loop detected: Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template loop detected: Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template loop detected: Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template loop detected: Template:Convert{{convert|8|cm|in|frac=4}}
→ Template loop detected: Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template loop detected: Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template loop detected: Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template loop detected: Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template loop detected: Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template loop detected: Template:Convert Template:Nay (double rounding)
Into multiple units: Template loop detected: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template loop detected: Template:Convert{{convert|5|km|mi nmi}}
→ Template loop detected: Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template loop detected: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template loop detected: Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template loop detected: Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template loop detected: Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template loop detected: Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template loop detected: Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template loop detected: Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template loop detected: Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template loop detected: Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template loop detected: Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template loop detected: Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template loop detected: Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template loop detected: Template:Convert{{convert|10|mi|m|spell=On}}
→ Template loop detected: Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template loop detected: Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template loop detected: Template:Convert
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 }}
→ Template loop detected: Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template loop detected: Template:Convert
After adjective unit: A Template loop detected: Template:Convert corridor
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}}
→ Template loop detected: Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre}}
→ Template loop detected: Template:Convert{{convert|2|metre|abbr=on}}
→ Template loop detected: Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template loop detected: Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template loop detected: Template:Convert
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}}
→ Template loop detected: Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template loop detected: Template:Convert{{convert|120|e6acre}}
→ Template loop detected: Template:Convert{{convert|120|e6acre|e3km2}}
→ Template loop detected: Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template loop detected: Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template loop detected: Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template loop detected: Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
- Template loop detected: Template:Convert
- Template loop detected: Template:Convert
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template loop detected: Template:ConvertMm
: Template loop detected: Template:Convertkm
: Template loop detected: Template:Convertmm
: Template loop detected: Template:Convertμm
: Template loop detected: Template:Convertum
: Template loop detected: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template loop detected: Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template loop detected: Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template loop detected: Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template loop detected: Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template loop detected: Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template loop detected: Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template loop detected: Template:Convert
Input with fractions: Template loop detected: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template loop detected: Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template loop detected: Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template loop detected: Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template loop detected: Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template loop detected: Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template loop detected: Template:Convert{{convert|1,234,567|m|ft}}
→ Template loop detected: Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template loop detected: Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template loop detected: Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template loop detected: Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x|…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template loop detected: Template:Convert{{convert|10|m|ft|disp=or}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template loop detected: Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template loop detected: Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template loop detected: Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template loop detected: Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template loop detected: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template loop detected: Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template loop detected: Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template loop detected: Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template loop detected: Template:Convert
Fixed ordering of output units: Template loop detected: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template loop detected: Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template loop detected: Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template loop detected: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template loop detected: Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template loop detected: Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template loop detected: Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template loop detected: Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template loop detected: Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template loop detected: Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template loop detected: Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template loop detected: Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template loop detected: Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template loop detected: Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template loop detected: Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template loop detected: Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template loop detected: Template:Convert | Template loop detected: Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template loop detected: Template:Convert
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
Template loop detected: Template:Convert
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para and Template:Para Template loop detected: Template:Convert Template:Para Template loop detected: Template:Convert Template:Para (default) Template loop detected: Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template loop detected: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template loop detected: Template:Convert B Template loop detected: Template:Convert C Template loop detected: Template:Convert D Template loop detected: Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template loop detected: Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template loop detected: Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template loop detected: Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template loop detected: Template:Convert{{convert|2|ft|3|in|cm}}
→ Template loop detected: Template:Convert{{convert|1|lb|5|oz|g}}
→ Template loop detected: Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template loop detected: Template:Convert{{convert|2|m|ft in}}
→ Template loop detected: Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template loop detected: Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template loop detected: Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template loop detected: Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template loop detected: Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template loop detected: Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template loop detected: Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template loop detected: Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template loop detected: Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template loop detected: Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.
Template:Convert navs Template:Sandbox other
{{convert|1200|ft|m|sigfig=3}}
→ Template:Convert{{convert|1200|ft|m|sigfig=2}}
→ Template:Convert{{convert|1200|ft|m|sigfig=1}}
→ Template:Convert
Default behaviour, for comparison:
{{convert|1200|ft|m}}
→ Template:Convert
Setting Template:Para to a value less than 1 is meaningless:
{{convert|1200|ft|m|sigfig=0}}
→ Template:Convert Template:Nay
Round to a multiple of 5: 15, 20, 25, ...
Using Template:Para rounds the outcome to a multiple of 5.
{{convert|10|m|ft}}
→ Template:Convert{{convert|10|m|ft|round=5}}
→ Template:Convert
Similar: using Template:Para rounds the outcome to a multiple of 25.
{{convert|10|m|ft}}
→ Template:Convert{{convert|10|m|ft|round=25}}
→ Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft|sigfig=4}}
→ Template:Convert
In a range, one can round each value individually to the default. Use Template:Para:
{{convert|10 x 200 x 3000|m|ft}}
→ Template:Convert{{convert|10 x 200 x 3000|m|ft|round=each}}
→ Template:Convert
Round to a multiple of a given fraction: Template:Frac inch
Specify the desired denominator using Template:Para. (Denominator is the below-the-slash number, for example the 3 in Template:Frac).
{{convert|5.56|cm|in|frac=16}}
→ Template:Convert{{convert|8|cm|in|frac=4}}
→ Template:Convert
The fraction is reduced when possible:
{{convert|8|cm|in|frac=100}}
→ Template:Convert
Default behaviour uses decimal notation:
{{convert|5.56|cm|in}}
→ Template:Convert
Template:AnchorRounding temperatures: °C, °F and K
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.
- {{#invoke:DemoTemplate|convert|10,000|C|F K}}
- {{#invoke:DemoTemplate|convert|10,000.1|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C|F K}}
- {{#invoke:DemoTemplate|convert|-272|C}}
- {{#invoke:DemoTemplate|convert|100|C|F K}}
- {{#invoke:DemoTemplate|convert|0|C|F K}}
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 Template:Convert, 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 Template:Para:
- {{#invoke:DemoTemplate|convert|10000|C|sigfig=5}}
or you set the precision positionally, relative to the decimal point (zero being at the decimal point):
- {{#invoke:DemoTemplate|convert|10000|C|0}}
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
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 Template:Tlc 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:
Note that there is no Template:ParaTemplate:Nay 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:
- Template:Tlc → Template:Convert Template:Nay (precisions are mismatched)
- Template:Tlc → Template:Convert Template:Aye
In this case, if the input were rounded before conversion, a different result would be obtained:
- Template:Tlc → Template:Convert Template:Nay (double rounding)
Into multiple units: Template:Convert
Separate the multiple output units by a space:
{{convert|10|C|F K}}
→ Template:Convert{{convert|5|km|mi nmi}}
→ Template:Convert
If the output unit names contain spaces, use +
as the separator.
See also:
- For multiple-unit options like 1 ft 5 in, see Template:Section link and Template:Section link.
Ranges of values
Template:For 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)
Range indicators are entered as the second parameter (between the values). Range separators can be:
Template:Convert/doc/range separator list
Multiple dimensions: Template:Convert
Use by
:
{{convert|6|by|12|ft|m}}
→ Template:Convert
Use ×
, multiplication sign, or x
, letter:
{{convert|6|x|12|m|ft}}
→ Template:Convert
In science, the formal way is to set |x|
and Template:Para (keeping dimensions right, like in area = x km2):
{{convert|6|x|12|m|ft|abbr=on}}
→ Template:Convert
Lists of values: 20, 40, or 60 miles
{{convert|20|,|40|, or|60|mi}}
→ Template:Convert
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:
{{convert|1|ft|3|in|x|3|ft|5|in|mm}}
→ Template:Convert Template:Nay
Default behaviour, for comparison:
{{convert|1|ft|3|in|mm}}
→ Template:Convert
However, converting metric units into feet and inches with Template:Para can produce the desired output:
{{convert|380|x|1040|mm|ftin|order=flip}}
→ Template:Convert
Words
Spelling of unit name: international metre or US meter?
Default spelling of units is in the en (generic) locale. To show en-US spelling, use Template:Para:
{{convert|1|m|ft}}
→ Template:Convert—default{{convert|1|m|ft|sp=us}}
→ Template:Convert
Spell out numbers: ten miles
To write a number in words, use Template:Para:
{{convert|10|mi|m|spell=in}}
→ Template:Convert
To spell out both in and out values, use Template:Para:
{{convert|10|mi|m|spell=on}}
→ Template:Convert
To make first letter a capital, use Template:Para, Template:Para
{{convert|10|mi|m|spell=In}}
→ Template:Convert{{convert|10|mi|m|spell=On}}
→ Template:Convert
Remember that the spelling of the units (ft, m) is independently set by Template:Para. To the extreme:
{{convert|10|mi|m|spell=on|abbr=off|sp=us}}
→ Template:Convert
Inserted before units: 4 planted acres
{{convert|4|acre||adj=pre|planted}}
→ Template:Convert
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 }}
→ Template:Convert{{convert|4|acre||disp=preunit|planted |reforested-}}
→ Template:Convert
After adjective unit: A Template:Convert corridor
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}}
→ Template:Convert
Plurals: 1 inch, 2 inches
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
{{convert|1|metre}}
→ Template:Convert{{convert|2|metre}}
→ Template:Convert{{convert|2|metre|abbr=on}}
→ Template:Convert
- Exception
Entering the unit spelled |foot|
forces singular output "foot", whatever the number is.
{{convert|100|foot|abbr=off}}
→ Template:Convert
Fractions: one-eighth of an imperial pint
The convert template also supports spelling out fractions.
{{convert|3+1/2|oz|g|spell=in}}
→ Template:Convert
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}}
→ Template:Convert
Wrapping and line breaking
Spelling out "thousands", "millions", etc.
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
{{convert|100|e6mi|e6km}}
→ Template:Convert{{convert|120|e6acre}}
→ Template:Convert{{convert|120|e6acre|e3km2}}
→ Template:Convert
To display both input and output in scientific notation, use Template:Para
{{convert|100|e6mi|e6km|abbr=on}}
→ Template:Convert
To spell out "thousands", "millions", etc., Template:Para abbreviates the unit; Template:Para displays both full unit names.
{{convert|100|e6mi|e6km|abbr=unit}}
→ Template:Convert{{convert|100|e6mi|e6km|abbr=off}}
→ Template:Convert
Numbers
Using an SI prefix: gigametre (Gm), or micrometre (μm)
Template: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:
The prefix can be added before the SI unit (here: unit m
for metre):
{{convert|12|Gm|mi|abbr=on}}
→ Template:ConvertMm
: Template:Convertkm
: Template:Convertmm
: Template:Convertμm
: Template:Convertum
: Template:Convert (letter "u" can be used for "μ" here)
The prefix can be used in the output unit:
{{convert|12000|mi|Mm|abbr=on}}
→ Template:Convert{{convert|12|in|μm|abbr=on}}
→ Template:Convert
As an exception, the non-SI unit "inch" can have the "μ" prefix too:
{{convert|12|μm|μin|abbr=on}}
→ Template:Convert
Engineering notation: 7 × 106 m
In the unit: e6m
Engineering notation can be entered as a "prefix" to the unit:
{{convert|70|e6m}}
→ Template:Convert
The same is possible for the output unit:
{{convert|23,000,000|ft|e6m}}
→ Template:Convert
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
In scientific notation, a number is written like Template:Rnd. The plain number has exactly one digit before the decimal point.
With Template:Tlf, 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}}
→ Template:Convert{{convert|0.00000005|atm|atm|abbr=on}}
→ Template:Convert
Input with fractions: Template:Convert
The number to convert can be written in fractions. Both /
(keyboard slash) and ⁄
(fraction slash) are accepted:
{{convert|1/2|in|mm|1}}
→ Template:Convert{{convert|1⁄2|in|mm|1}}
→ Template:Convert
With positive mixed numbers (a positive integer and a fraction), use a +
sign
{{convert|2+1⁄2|in|mm|1}}
→ Template:Convert
With negative mixed numbers, use a hyphen -
and repeat it:
{{convert|-2-1⁄2|in|mm|1}}
→ Template:Convert
Note that the following cases are not interpreted as mixed numbers:
{{convert|2-1⁄2|in|mm|1}}
→ Template:Convert. This is interpreted as a range from 2 inches to 1⁄2 inch.{{convert|-2+1⁄2|in|mm|1}}
→ Template:Convert Template:Nay This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
Horizontal fraction bar: Template:Sfrac inch
Using a double slash (//
) provides a horizontal fraction bar for the original (input) unit:
{{convert|1//2|in|mm|1}}
→ Template:Convert{{convert|6+3//8|in|mm|1}}
→ Template:Convert
Using a negative value for Template:Para provides a horizontal fraction bar for the converted (output) unit:
{{convert|12.7|mm|frac=-2}}
→ Template:Convert{{convert|161.9|mm|frac=-8}}
→ Template:Convert
Thousands separator: 1,000 mi or 1000 mi
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}}
→ Template:Convert{{convert|1,234,567|m|ft}}
→ Template:Convert
Set Template:Para to remove the separator from the output:
{{convert|1234567|m|ft|comma=off}}
→ Template:Convert
Use Template:Para to use digit grouping by gap (thin space) as a thousands separator:
{{convert|1234567|m|ft|comma=gaps}}
→ Template:Convert
Default behaviour, for comparison:
{{convert|1234567|m|ft}}
→ Template:Convert
Setting Template:Para will only add the separator when the number of digits is 5 or more:
{{convert|1234|m|ft|comma=5}}
→ Template:Convert{{convert|1234567|m|ft|comma=5}}
→ Template:Convert
Default behaviour, for comparison:
{{convert|1234|m|ft}}
→ Template:Convert
Output manipulation
Brackets and separators: 10 m [33 ft]
Punctuation that distinguishes the two measurements is set by Template:Para.
Options are: b
(the default), sqbr
, comma
, or
, br
, x!…
:
{{convert|10|m|ft|disp=sqbr}}
→ Template:Convert{{convert|10|m|ft|disp=comma}}
→ Template:Convert{{convert|10|m|ft|disp=or}}
→ Template:Convert
Default behaviour, for comparison:
{{convert|10|m|ft}}
→ Template:Convert
Setting Template:Para will force a new line (<br/>
)
{{convert|10|m|ft|disp=br}}
→ Template:Convert
Also Template:Para will force a new line, and keep the brackets (useful in tables):
{{convert|10|m|ft|disp=br()}}
→ Template:Convert
Setting Template:Para allows any text as separator:
{{convert|10|m|ft|disp=x|_MyText_}}
→ Template:Convert (To display spaces, use
)
Flipping (reordering) the two measurements: Template:Convert
Setting Template:Para will flip (swap) the two measurements:
{{convert|1|mi|m|order=flip}}
→ Template:Convert
Default behaviour, for comparison:
{{convert|1|mi|m}}
→ Template:Convert
When converting to multiple units, the effect is:
{{convert|10|km|mi nmi|order=flip}}
→ Template:Convert{{convert|10|km|nmi mi|order=flip}}
→ Template:Convert
Fixed ordering of output units: Template:Convert
Setting Template:Para shows the output-units as ordered; the input unit is skipped:
{{convert|100|C|F C K|abbr=on|order=out}}
→ Template:Convert{{convert|200|PS|kW hp|0|abbr=on|order=out}}
→ Template:Convert
See also: § Displaying parts of the output.
Displaying parts of the result: Template:Convert
It is possible to display only parts of the conversion result:
Convert | Output | Returns |
---|---|---|
{{convert|2|cuyd|m3}} |
Template:Convert | Regular output (for comparison) |
{{convert|2|cuyd|m3|abbr=values}}
|
Template:Convert | Input and output numbers |
{{convert|2|cuyd|m3|disp=unit}} |
Template:Convert | Input unit |
{{convert|2|cuyd|m3|disp=unit|adj=on}} |
Template:Convert | Input unit, adjective (hyphenated) |
{{convert|2|cuyd|cuyd|disp=out}} |
Template:Convert | Input (workaround. Template:Nowrap) |
{{convert|2|cuyd|m3|abbr=~}} |
Template:Convert | Input: both name and symbol |
{{convert|2|cuyd|m3|disp=unit2}} |
Template:Convert | Output unit (symbol) |
{{convert|2|cuyd|m3|disp=unit2|abbr=off}} |
Template:Convert | Output unit (name) |
{{convert|2|cuyd|m3|disp=number}} |
Template:Convert | Output value |
{{convert|2|cuyd|m3|disp=out}} |
Template:Convert | Output value and unit name |
{{convert|2|cuyd|m3|disp=out|abbr=off}} |
Template:Convert | Output value and unit symbol |
Display both input name and symbol: 2 kilopascals [kPa]
Setting Template:Para returns both name and symbol of the first (input) unit:
{{convert|2|kPa|psi|abbr=~}}
→ Template:ConvertA {{convert|2|kPa|psi|abbr=~|adj=on}} pressure
→ Template:Nowrap
Table options
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
Template:Para adds a line-break and omits brackets.
Template:Para adds a line-break and does add brackets to the converted value. This may be useful in tables:
Template:Para | Template:Para |
---|---|
Template:Convert | Template:Convert |
Table columns
Using {convert} in a table cell, with Template:Para splits the result over two (or more) columns. By default units are not included in the table, however, they can be added using the Template:Para parameter. Multiple-unit outputs, like ftin
, always output their units to the table.
{{convert|10|m|ft|disp=table}}
→
Template:Para does the same, and also centers the text:
{{convert|20|m|ft|disp=tablecen}}
→
The units are added as a column header:
kilograms pounds stone and pounds Template:Para Template:Convert Template:Para and Template:Para Template:Convert Template:Para and Template:Para Template:Convert Template:Para Template:Convert Template:Para (default) Template:Convert
Sorting
Use Template:Para 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}}
Template:Nowrap- showing: Template:Convert.
Use both Template:Para and Template:Para together to produce table columns (pipe symbols) for each value in sortable columns:
m ft A Template:Convert B Template:Convert C Template:Convert D Template:Convert
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
The conversion factors and physical constants are sourced here.
All units
Template:Selfref Template:Hatnote Template:Convert/list of units
Template:Anchor'per' units: kg/hl, miles per gallon
When using a slash (/
), a unit like kg/hl
is recognized as kilograms per hectolitre and will be converted with other mass/volume units.
{{convert|1000|kg/hl}}
→ Template:Convert
Population density (inhabitants per square mile) can be converted using
{{convert|10|PD/sqmi|PD/km2}}
→ Template:Convert
Vehicular fuel efficiency, commonly expressed in miles per gallon or litres per 100 km can also be converted
{{convert|26|mpgUS|l/100km mpgimp}}
→ Template:Convert
Template:AnchorUnits of difference: Expressing a change or difference in temperature
We have already discussed standard temperature conversions (°C, °F, K), as shown in these two examples:
- {{#invoke:DemoTemplate|convert|10|C}} (standard temperature conversion)
- {{#invoke:DemoTemplate|convert|10–15|C}} (standard temperature range conversion)
When expressing a temperature change (e.g., "The temperature increased by 10 °C"), or when comparing temperatures (e.g., "10 to 15 °C warmer"), we cannot use the standard temperature units (Template:Para, Template:Para and Template:Para), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": Template:Para, Template:Para and Template:Para.
Compare the following two examples with the two above:
- {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
- {{#invoke:DemoTemplate|convert|10–15|C-change}} warmer than normal
To produce multiple units in the output:
- {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}} difference
Multiple units: 1 ft 5 in
In input
Base document Template:Slink lists options for multiple unit input (like ft,in
). It can catch predefined sets only (units that can be subdivided; e.g., yd into ft):
{{convert|1|yd|2|ft|3|in}}
→ Template:Convert{{convert|2|ft|3|in|cm}}
→ Template:Convert{{convert|1|lb|5|oz|g}}
→ Template:Convert
In output
Available multiple-unit output options predefined, like ftin
and ydftin
. The full list is at Template:Slink.
{{convert|2|m|ftin}}
→ Template:Convert{{convert|2|m|ft in}}
→ Template:Convert, using a space, returns the decimal point
Default behaviour, for comparison:
{{convert|2|m}}
→ Template:Convert
See also:
- Template:Tl a length used to measure horses
- Template:Tl a weight in ton, cwt, qr and lb
Currency per unit: $/mi → $/km
Using currency symbols in a $ per unit value, you can convert the per-unit:
{{convert|10|$/mi|$/km}}
→ Template:Convert{{convert|1500|$/ozt|$/g}}
→ Template:Convert
You can set the currency in both values using Template:Para:
{{convert|10|$/mi|$/km|$=€}}
→ Template:Convert
It is not possible to convert the currency. So, this result (mixed currencies) is not possible: Template:!mxt Template:Nay
Using convert inside templates
For usage in template code, like infoboxes, Template:Tlf has these options:
- Pre-formatting fraction input
- Module:Convert/helper can read regular input and pre-format it into Template:Tlf-accepted input.
- Your template can accept Template:Para and use {{#invoke:Convert/helper|number|16 7/8}} → {{#invoke:Convert/helper|number|16 7/8}}
- Using a Wikidata property
- Adding the Wikidata property code, like code Template:Para, to your template code automatically returns the Wikidata property for that article, and convert it. Both number and unit are read.
Note: to return that property value for an other article, use Template:Para.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
→ Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on}}
→ Template:Convert{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
→ Template:Convert
- For example see template:Infobox Telescope.
Sometimes a property may have more than one value against it in Wikidata. You can use the Template:Para parameter to specify which of the values you want to use.
Example for Template:Wikidata property link: Note: this example uses Template:Para (testing for Template:Wikidata entity link)
- Template:Wikidata entity link:
{{convert|input=P2386|qual=Q613628|ft|abbr=on}}
→ Template:Convert - Template:Wikidata entity link:
{{convert|input=P2386|qual=Q1395645|ft|abbr=on}}
→ Template:Convert
Parameter list
Template:Convert/doc/parameter list
Deprecated options
Template:Convert/doc/deprecations list
TemplateData
<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 }, "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 }, "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.", "default": "off", "type": "string", "example": "on" }, "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 }, "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" }, "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" }, "order": { "label": "Ordering", "description": "“flip” returns converted value first, input value second.", "type": "string", "example": "flip" }, "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": "string", "example": "off" }, "sortable": { "label": "Sort key", "description": "“on” generates a hidden sort key", "type": "string", "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" }, "sing": { "type": "string", "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": "Template:Convert (P2046=area)", "type": "string" } }, "format": "inline" } </templatedata>
See also
- Template:Temp
- Template:Temp
- Template:Temp to convert historical prices to their current equivalent.