From WikiSwire
< Template:Convert‎ | doc(Redirected from Template:Convert/FAQ)
Jump to: navigation, search

Template:FAQ page Note: This page was just created 22 November 2010, and is still being expanded.

Most common questions

Q: When using {{convert}} why does the answer not seem right sometimes?
A: This template takes into account the precision of the supplied value and generally rounds to the same level of precision. If you need to change from the default output precision, see the "Rounding" section of the template documentation.
Q: What are all the possible units (kg, lb, m, cm, ft, in, °C, °F, km, mi, nmi, mph, km/h, and so on)?
A: See: Template:Convert/list of units.

Showing words with conversions

Q: Can a conversion say "million" rather than use zeroes "000,000"?
A: Yes, there many unit codes with prefixes e3/e6/e9 to show "thousand" or "million" or "billion" units (such as: e6acre, to show "million acres"). The output unit code can also use the e3/e6/e9 prefix, or use typical units to show input "million" but output with zeroes "000". Some examples:
  • {{convert|14|e6acre}} → 14 million acres (57,000 km2)
  • {{convert|14|e6acre|ha}} → 14 million acres (5,700,000 ha)
  • {{convert|1|e6mi}}        → 1 million miles (1.6×10^6 km)
  • {{convert|2.2|e6mi|e6km|abbr=on}} → 2.2×10^6 mi (3.5×10^6 km)
  • {{convert|3.3|e6mi|km}}           → 3.3 million miles (5,300,000 km)
For a list of the other e3/e6/e9 units, see: Template:Convert/list of units.

Q: How are customized, extra words shown within a conversion?
A: Append "disp=x|aaa|bbb" where "aaa" is the text after the input amount and "bbb" is shown after the output amount. Examples:
  • {{convert|9|m|ft|disp=x| or }}           → 9 metres or 30 ft
  • {{convert|9|m|ft|disp=x| wide (|)}}     → 9 metres wide (30 ft)
  • {{convert|4|m|ft|disp=x|, equal to }} → 4 metres, equal to 13 ft
  • {{convert|2|mi|ft m|disp=x| deep, same as }} → 2 miles deep, same as 11,000 ft; 3,200 m
When using disp=x, then the parentheses "( )" are turned off for that conversion, but can be re-added (as "disp=x|deep (|)" for example). However, inserting "or" is common. There is no limit to the total number of words inserted in a conversion. For example:
  • {{convert|35|cm|in|abbr=off|disp=x| maximum width, as required by law (|)}}
         → 35 centimetres maximum width, as required by law (14 inches)
In many cases, "bbb" can be omitted because the text following a conversion is, essentially, the "bbb" as the continued text of the article. Sometimes, extra words can be inserted just to break the monotony of many conversions in a row: "aa miles (bb km), cc miles (dd km), and eee miles (same as fff km)".

Changing the format

Q: How can we reverse the order of input and output units?
A: Using "disp=flip" reverses the order, or flips the units, so that the input unit is displayed in reverse order, as being the output unit. Examples:
  • {{convert|23|km|disp=flip}}          → 14 miles (23 km)
  • {{convert|9|m|disp=flip}}            → 30 feet (9 m)
  • {{convert|9|m|disp=flip|abbr=out}} → 30 feet (9 m)
  • {{convert|27|mm|disp=flip}} → 1.1 inches (27 mm)
  • {{convert|6|ft|2|in|cm|disp=flip}} → 188 cm (6 feet 2 inches)
  • {{convert|6|ft|2|in|cm|disp=flip|abbr=out}} → 188 centimetres (6 ft 2 in)
Flipping the units is common when a source document uses metric numbers but the article doesn't, such as a British news source quoting "metres" about an American topic using feet as typical in American English. So, the display is reversed, showing feet first, then the source metres in "( )".

Q: How can we show just the output amount and omit the input?
A: Convert allows "disp=out" (or "disp=output only") to show only the output amount/unit, and omit the parentheses "( )". Examples:
  • {{convert|6|ft|cm|disp=out}} → 180 cm
  • {{convert|97|km|disp=out}} → 60 mi
  • {{convert|97|km|disp=out|abbr=off}} → 60 miles
To show just the number (not the unit), use disp=number (or "disp=output number only"):
  • {{convert|6|ft|cm|disp=number}} → 180
  • {{convert|97|km|disp=number}} → 60
The option "abbr=off" can stop the abbreviations and show output with a full unit name, rather than the unit symbol.

Q: How can we show just the output unit name (singular/plural) and omit the amount?
A: Convert has option "disp=u2" (for unit 2) to show only the output unit name (or unit symbol), and omit the parentheses "( )" and amount. Examples:
  • {{convert|6|ft|cm|disp=b}} → 6 feet (180 cm)
  • {{convert|6|ft|cm|disp=u2}} → cm
  • {{convert|97|km|disp=u2}} → mi
  • {{convert|97|km|disp=u2|abbr=off}} → miles
The option "disp=unit" (shown below) will show the input unit name (or unit symbol), rather than the output unit name.

Q: How can we show just the unit name and omit the numbers?
A: Convert allows "disp=unit" to show only the unit name or unit symbol. Examples:
  • {{convert|6|ft|disp=unit}} → feet
  • {{convert|1|ft|disp=unit}} → foot
  • {{convert|4|cuyd|disp=unit}} → cubic yards
  • {{convert|1|km/h|disp=unit}} → kilometre per hour
  • {{convert|1|km2|disp=unit|abbr=on}} → km2
The option "disp=unit" is typically used to select either the singular, or plural, name for an amount of a particular unit, but it can also show a formal unit symbol by including "abbr=on" with a unit code.

Performance concerns

Q: Convert seems big, but can Convert run faster as used?
A: An attempt has been made to optimize Convert to run in groups of tiny templates. However, setting the precision can avoid almost half of those templates, such as round by 0, 1 or set sigfig=3 (or similar). In many cases, just round as "|0" or for thousands, use "|-3". Some examples:
  • {{convert|9|m|ft}}        → 9 metres (30 ft)   [ default ]
  • {{convert|9|m|ft|0}}     → 9 metres (30 ft)   [ round 0 ]
  • {{convert|9|m|ft|1}}     → 9 metres (29.5 ft) [ round 1 ]
  • {{convert|9000|m|ft|0}}     → 9,000 metres (29,528 ft)   [ round 0 ]
  • {{convert|9000|m|ft|-3}}     → 9,000 metres (30,000 ft)   [ round -3 ]
  • {{convert|9000|m|ft|sigfig=2}}     → 9,000 metres (30,000 ft)
  • {{convert|32|m|ft}}        → 32 metres (105 ft) [ default ]
  • {{convert|32|m|ft|0}}     → 32 metres (105 ft) [ round 0 ]
  • {{convert|32|m|ft|disp=x| high (|)|1}}     → 32 metres high (105.0 ft) [ round 1 ]

Q: Convert seems to cause some red error messages, why?
A: There are some other large templates which consume resources needed when using Convert inside those templates:
: Nest 20 templates & use {Convert|9|m}:
}}}} }}}} }}}} }}}} }}}}  }}}} }}}} }}}} }}}} }}}}
Nest 20 templates & use {Convert|9|m}: 9 metres ({{rnd/bExpression error: Unexpected < operator.|Expression error: Unexpected < operator.|(Expression error: Unexpected < operator.)|Expression error: Unexpected < operator. }} ft)
Nest 20 templates & use {Convert|9|m|0}: 9 metres (30 ft)
Other Wikipedia templates might be using many levels of nested logic, leaving fewer for Convert. Convert has been optimized to run in groups of tiny templates. However, setting the precision can avoid several of those nested templates, such as round by 0, 1 or set sigfig=2 (or similar). In many cases, just round as "|0" or for thousands, use "|-3". Some examples:
  • {{convert|7|m|ft|0}}     → 7 metres (23 ft)   [ round 0 ]
  • {{convert|7000|m|ft|0}}     → 7,000 metres (22,966 ft)   [ round 0 ]
  • {{convert|7000|m|ft|-3}}     → 7,000 metres (23,000 ft)   [ round -3 ]
  • {{convert|7000|m|ft|sigfig=2}}     → 7,000 metres (23,000 ft)
Using either rounding by "0" or sigfig=3 (or such) will reduce the nested Convert templates by the same 8-11 nested levels to allow using more templates.

Writing new unit subtemplates

Q: The unit I need is not in the list, so can I create a subtemplate for it?
A: Yes, Convert allows anyone to create a new unit subtemplate, of the form Template:Convert/myunit, to handle a new unit-code named "myunit" by copying another unit subtemplate.
The process, for creating a subtemplate to convert a new unit-code, is explained on the page:
    "WP:Advanced Convert coding#Defining new conversion subtemplates".
However, due to markup complexity, instead many users ask, at the bottom of the talk-page, Template_talk:Convert, for a more-experienced user to create the new subtemplate.

Q: When I reverse a conversion, from a→b to b→a, why is it off by 1 million (1,000,000)?
A: Sometimes, a new unit has a coding error. Inside a unit subtemplate, the parameter b also acts as a conversion divisor and needs to use outer parentheses "( )" in the calculation.
Beware a multiplication:  b=(45/9)*1000,
which needs outer "( )":   b=( (45/9)*1000 )  to keep the "1000" in the divisor. Without the outer parentheses, the " *1000" would increase the calculation by 1,000x bigger, rather than 1,000x smaller, so the overall result zooms off by 1,000×1,000 or 1,000,000, as being 1 million too big.

See also