Jump to content

User:Moondyne/Convert

From Wikipedia, the free encyclopedia

Abridged instructions for the {{convert}} template.

  • 1st parameter is the number to convert.
  • 2nd is the unit code.
  • 3rd (optional) is the unit code to convert to. Most units have a logical default unit to convert to and are therefore mostly unnecessary. eg. "km" converts to "mi" unless you override it. (see example 2)
  • 4th (optional) is the rounding number. ie. 0 = whole number; 1 = tenths; 2 = hundredths. (see examples 3 & 4)

Examples

[edit]
  1. {{convert|100|km}} → 100 kilometres (62 mi)
  2. {{convert|100|km|ft}} → 100 kilometres (330,000 ft) -- overriding convert-to unit
  3. {{convert|100|acre|ha|2}} → 100 acres (40.47 ha) -- rounding to 2 decimals
  4. {{convert|100|acre|ha|0}} → 100 acres (40 ha) -- rounding to 0 decimals

Some common unit codes

[edit]
Metric
  • m = metres
  • ha = hectare
  • km = kilometre
  • km2 = square kilometre
  • kg = kilogram
Imperial
  • mi = mile
  • ft = foot
  • in = inch
  • sqmi = square mile
  • lb = pound
  • acre = acre

Optional switches

[edit]
  • |abbr=on → displays 2 letter abbreviated units
  • |lk=on → units are linked
  • |sigfig={some non-negative integer} → display significant figures
  • |disp=table → for use in tables. Result shows over 2 columns inside a table

More examples

[edit]
  1. {{convert|100|acre|ha sqmi}} → 100 acres (40 ha; 0.16 sq mi)
  2. {{convert|33|Tcuft|km3}} → 33 trillion cubic feet (930 km3)
  3. {{convert|100|km|abbr=on}} → 100 km (62 mi)
  4. {{convert|100|km|abbr=on|lk=on}} → 100 km (62 mi)
  5. {{convert|6|ft|5|in|m|2}} → 6 feet 5 inches (1.96 m)
  6. {{convert|60|to(-)|170|kg|lb}} → 60 to 170 kilograms (130–370 lb)