Template:Convert: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Drew R. Smith
No edit summary
imported>Caesar Schinas
m (Remove double space after first number)
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{#ifeq:{{{5|}}}|plain||{{{1}}}&nbsp;{{{2}}} (}}{{#expr:(
<includeonly>{{#ifeq:{{{5|}}}|plain||{{#if:{{{6|}}}|{{{6}}}|{{{1}}} }}&nbsp;{{{2}}} (}}{{#expr:(
{{#switch:{{{2}}}
{{#switch:{{lc:{{{2}}}}}
|mm|millimetre|millimetres|millimeter|millimeters =  
|mm|millimetre|millimetres|millimeter|millimeters =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |in|inch|inches                     = {{{1}}} / 25.4
     |in|inch|inches                     = {{{1}}} / 25.4
     |ft|foot|feet                       = {{{1}}} / 304.8
     |ft|foot|feet                       = {{{1}}} / 304.8
     }}
     }}
|cm|centimetre|centimetres|centimeter|centimeters =  
|cm|centimetre|centimetres|centimeter|centimeters =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |in|inch|inches                     = {{{1}}} / 2.54
     |in|inch|inches                     = {{{1}}} / 2.54
     |ft|foot|feet                       = {{{1}}} / 30.48
     |ft|foot|feet                       = {{{1}}} / 30.48
     }}
     }}
|dm|decimetre|decimetres|decimeter|decimeters =  
|dm|decimetre|decimetres|decimeter|decimeters =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |in|inch|inches                     = {{{1}}} / 0.254
     |in|inch|inches                     = {{{1}}} / 0.254
     |ft|foot|feet                       = {{{1}}} / 3.048
     |ft|foot|feet                       = {{{1}}} / 3.048
     }}
     }}
|m|metre|metres|meter|meters =  
|m|metre|metres|meter|meters =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |in|inch|inches                     = {{{1}}} / 0.0254
     |in|inch|inches                     = {{{1}}} / 0.0254
     |ft|foot|feet                       = {{{1}}} / 0.3048
     |ft|foot|feet                       = {{{1}}} / 0.3048
     |yd|yard|yards                     = {{{1}}} / 0.9144
     |yd|yard|yards                       = {{{1}}} / 0.9144
     |mi|mile|miles                     = {{{1}}} / 1609.344
     |mi|mile|miles                       = {{{1}}} / 1609.344
     |nmi|nautical mile|nautical miles   = {{{1}}} / 1852
     |nm|nmi|nautical mile|nautical miles = {{{1}}} / 1852
     }}
     }}
|km|kilometre|kilometres|kilometer|kilometers =  
|km|kilometre|kilometres|kilometer|kilometers =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |yd|yard|yards                     = {{{1}}} * 1093.6133
    |ft|foot|feet                        = {{{1}}} / 0.0003048
     |mi|mile|miles                     = {{{1}}} * 0.621371192
     |yd|yard|yards                       = {{{1}}} * 1093.6133
     |nmi|nautical mile|nautical miles   = {{{1}}} / 1.852
     |mi|mile|miles                       = {{{1}}} * 0.621371192
     |nm|nmi|nautical mile|nautical miles = {{{1}}} / 1.852
     }}
     }}


|in|inch|inches =  
|in|inch|inches =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |mm|millimetre|millimetres         = {{{1}}} * 25.4
     |mm|millimetre|millimetres           = {{{1}}} * 25.4
     |cm|centimetre|centimetres         = {{{1}}} * 2.54
     |cm|centimetre|centimetres           = {{{1}}} * 2.54
     |dm|decimetre|decimetres           = {{{1}}} * 0.254
     |dm|decimetre|decimetres             = {{{1}}} * 0.254
     |m|metre|metres                     = {{{1}}} * 0.0254
     |m|metre|metres                     = {{{1}}} * 0.0254
     }}
     }}
|ft|foot|feet =  
|ft|foot|feet =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |mm|millimetre|millimetres         = {{{1}}} * 304.8
     |mm|millimetre|millimetres           = {{{1}}} * 304.8
     |cm|centimetre|centimetres         = {{{1}}} * 30.48
     |cm|centimetre|centimetres           = {{{1}}} * 30.48
     |dm|decimetre|decimetres           = {{{1}}} * 3.048
     |dm|decimetre|decimetres             = {{{1}}} * 3.048
     |m|metre|metres                     = {{{1}}} * 0.3048
     |m|metre|metres                     = {{{1}}} * 0.3048
     |km|kilometre|kilometres           = {{{1}}} * 0.0003048
     |km|kilometre|kilometres             = {{{1}}} * 0.0003048
     }}
     }}
|yd|yard|yards =  
|yd|yard|yards =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |mm|millimetre|millimetres         = {{{1}}} * 914.4
     |mm|millimetre|millimetres           = {{{1}}} * 914.4
     |cm|centimetre|centimetres         = {{{1}}} * 91.44
     |cm|centimetre|centimetres           = {{{1}}} * 91.44
     |dm|decimetre|decimetres           = {{{1}}} * 9.144
     |dm|decimetre|decimetres             = {{{1}}} * 9.144
     |m|metre|metres                     = {{{1}}} * 0.9144
     |m|metre|metres                     = {{{1}}} * 0.9144
     |km|kilometre|kilometres           = {{{1}}} * 0.0009144
     |km|kilometre|kilometres             = {{{1}}} * 0.0009144
     }}
     }}
|mi|mile|miles =  
|mi|mile|miles =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |m|metre|metres                     = {{{1}}} * 1609.344
     |m|metre|metres                     = {{{1}}} * 1609.344
     |km|kilometre|kilometres           = {{{1}}} * 1.609344
     |km|kilometre|kilometres             = {{{1}}} * 1.609344
     |nmi|nautical mile|nautical miles   = {{{1}}} * 0.868976242
     |nm|nmi|nautical mile|nautical miles = {{{1}}} * 0.868976242
     }}
     }}
|nmi|nautical mile|nautical miles =  
|nm|nmi|nautical mile|nautical miles =  
     {{#switch:{{lc:{{{3}}}}}
     {{#switch:{{lc:{{{3}}}}}
     |m|metre|metres                     = {{{1}}} * 1852
     |m|metre|metres                     = {{{1}}} * 1852
     |km|kilometre|kilometres           = {{{1}}} * 1.852
     |km|kilometre|kilometres             = {{{1}}} * 1.852
     |mi|mile|miles                     = {{{1}}} * 1.15077945
     |mi|mile|miles                       = {{{1}}} * 1.15077945
     }}
     }}
|F|°F|Fahrenheit =  
 
     {{#switch:{{{3}}}
|kg|kilogramme|kilogrammes|kilogram|kilograms =
     |C|°C|Celsius = ({{{1}}} - 32) * (5 / 9)
     {{#switch:{{lc:{{{3}}}}}
     |K|°K|Kelvin = (5 / 9) * ({{{1}}} - 32) + 273
    |lbs|pound|pounds    = {{{1}}} * 2.2046
     |R|°R|Rankine = {{{1}}} + 459.69
     |oz|ounce|ounces    = {{{1}}} * 35.273
    }}
|g|gramme|grammes|gram|grams =
    {{#switch:{{lc:{{{3}}}}}
    |lb|lbs|pound|pounds = {{{1}}} * .0022046
    |oz|ounce|ounces    = {{{1}}} * .035273
    }}
|lb|lbs|pound|pounds =
    {{#switch:{{lc:{{{3}}}}}
    |g|gramme|grammes|gram|grams                  = {{{1}}} * 453.6
    |kg|kilogramme|kilogrammes|kilogram|kilograms = {{{1}}} * .4536
    }}
|oz|ounce|ounces =
    {{#switch:{{lc:{{{3}}}}}
    |g|gramme|grammes|gram|grams                  = {{{1}}} * 28.35
     |kg|kilogramme|kilogrammes|kilogram|kilograms = {{{1}}} * .02835
    }}
 
|°c|celsius|centigrade =
    {{#switch:{{lc:{{{3}}}}}
    |°k|kelvin            = {{{1}}} + 273
     |°f|fahrenheit        = {{{1}}} * (9/5) + 32
    |°r|rankine            = {{{1}}} * (9/5) + 491.67
     }}
     }}
|C|°C|Celsius =
|°f|fahrenheit =  
     {{#switch:{{{3}}}
     {{#switch:{{lc:{{{3}}}}}
     |F|°F|Fahrenheit = {{{1}}} * (9 / 5) + 32
     |°r|rankine            = {{{1}}} + 459.69
     |K|°K|Kelvin = {{{1}}} + 273
     |°c|celsius|centigrade = ({{{1}}} - 32) * (5/9)
     |R|°R|Rankine = {{{1}}} * (9 / 5) + 491.67
     |°k|kelvin            = ({{{1}}} - 32) * (5/9) + 273
     }}
     }}
}}
}}
) round {{{4|2}}} }}{{#ifeq:{{{5|}}}|plain||&nbsp;{{{3}}})}}</includeonly><noinclude>{{TlDoc}}</noinclude>
) round {{{4|2}}} }}{{#ifeq:{{{5|}}}|plain||&nbsp;{{{3}}})}}</includeonly><noinclude>{{TlDoc}}</noinclude>

Latest revision as of 09:42, 11 October 2010

This documentation is transcluded from Template:Convert/doc (edit | history)

This template is used in articles to easily convert one unit to another. This template will always be under construction, as we can’t possibly include conversions from every possible unit to every possible unit. Should you find a combination of unis which isn't supported but which you think should be, please leave a note on the talk page and it will be added.
The goal of this template is to make the Citizendium accessible to all readers regardless of nationality. Instead of only showing SI/Metric units or Imperial units, {{convert}} automatically converts a number from the specified unit to another unit and displays it as "Metric (Imperial)" or "Imperial (Metric)", depending on which unit was converted from.

Usage

The template has five parameters - {{convert|number|from|to|precision|plain}}.

  1. required — The number to convert.
  2. required — The unit to convert from.
  3. required — The unit to convert to.
  4. optional — The precision of the result. Positive values cause the specified number of decimal places to be shown, whilst negative values cause the numbers to be rounded to the specified number of significant figures. The default value is 2 (2 decimal places).
  5. optional — set the 5th parameter to "plain" to make the template output a plain number, without units and without the input number. If this is used, the previous parameter must be given a value.

The names of the units can be specified as either abbreviations or full words, using either British or American spelling. The unit names in the output will be in the same format as the input.

Examples

Code Result Notes
{{convert|123.4|km|mi}} 123.4 km (76.68 mi) Simple conversion of 123.4 kilometres to miles.
{{convert|12|in|cm|0}} 12 in (30 cm) Convert 12 in to cm, rounding to the nearest whole cm.
{{convert|60|nmi|mi|6}} 60 nmi (69.046767 mi) Convert 60 nautical miles to statute miles, showing the result to 6 decimal places.
{{convert|60|nautical miles|miles|-1}} 60 nautical miles (70 miles) Convert 60 nautical miles to statute miles, and round the result to one significant figure.

Supported Conversions

Transcluded from Template:Convert/doc/conversions (edit)

Length Conversions

Metric to Imperial

Inches (in) Feet (ft) Yards (yd) Miles (mi) Nautical Miles (nmi)
Millimetres (mm) Yes Yes No No No
Centimetres (cm) Yes Yes No No No
Decimetres (dm) Yes Yes No No No
Metres (m) Yes Yes Yes Yes Yes
Kilometres (km) No No Yes Yes Yes

Imperial to Metric

Millimetres (mm) Centimetres (cm) Decimetres (dm) Metres (m) Kilometres (km)
Inches (in) Yes Yes Yes Yes No
Feet (ft) Yes Yes Yes Yes Yes
Yards (yd) Yes Yes Yes Yes Yes
Miles (mi) No No No Yes Yes
Nautical Miles (nmi) No No No Yes Yes

Imperial to Imperial

Miles (mi) Nautical Miles (nmi)
Miles (mi) - Yes
Nautical Miles (nmi) Yes -

Weight Conversions

Kilogrammes (kg) Grammes (g) Pounds (lbs) Ounces (oz)
Kilogrammes (kg) - No Yes Yes
Grammes (g) No - Yes Yes
Pounds (lbs) Yes Yes - No
Ounces (oz) Yes Yes No -

Temperature Conversions

Celsius (°C) Kelvin (°K) Fahrenheit (°F) Rankine (°R)
Celsius (°C) - Yes Yes Yes
Kelvin (°K) Yes - Yes No
Fahrenheit (°F) Yes Yes - Yes
Rankine (°R) Yes No Yes -

For in-depth information, see the detailed list.