ಟೆಂಪ್ಲೇಟು:Convert/doc/FAQ

ವಿಕಿಪೀಡಿಯದಿಂದ, ಇದು ಮುಕ್ತ ಹಾಗೂ ಸ್ವತಂತ್ರ ವಿಶ್ವಕೋಶ

Note: To find topics about Template:Convert (or Template:Convert/old), either read each of the dozen questions, below, or search for key phrases used within the page. In some cases, it might be easier to just rapidly scan by "speed reading" all the questions, to get other ideas about using Convert. For a list of all parameter options, see: Template:Convert/doc. Major versions:

  • {{Convert}}      – main version used in nearly 600,000 pages[೧]
  • {{Convert/old}} – markup version used for extra features

The Lua version of Convert uses Module:Convert, Module:Convert/data, Module:Convert/text and Module:Convert/extra, etc.

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 the output to the same level of precision. If you need to change from the default output precision, see Help:Convert.
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: Help:Convert 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"). Using the "e6acre" (or "e9acre") form will get rid of all the zeroes for converting acres. 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|e9mi|km}}                 → 3.3 billion miles (5.3×109 km)
  • {{convert|3.3|e9mi|e9km|abbr=off}} → 3.3 billion miles (5.3 billion kilometres)
Note the output unit code can also use the e3/e6/e9 prefix, but will show x10 notation unless "abbr=off" is set, to show "million" or "billion" in the output amount. Otherwise, using the typical output units would show input "million" but output with zeroes "000".
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: There are 2 options: disp=x, or disp=preunit. Append "disp=x|aaa|bbb" (where "aaa" is the text after the input amount and "bbb" is after the output amount). Use "disp=preunit|aaa|bbb" to insert text prior to each unit. 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
Insert text prior to units, by disp=preunit:
  • {{convert|4|m|ft|disp=preunit|linear }}       → 4 linear metres (13 linear ft)
  • {{convert|4|m|ft|disp=preunit|full | |2}} → 4 full metres (13.12 ft)
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)".

Q: How can numbers be spelled-out in words for a conversion?
A: Use "{{convert/spell}}" to spell-out the first number or both amounts in words (append "|words=out" to spell both numbers in words). Examples:
  • {{convert/spell |29|m|ft}}       → twenty-nine metres (೯೫ 29 m (95 ft)*)
  • {{convert/spell |6,031|km|mi}}              → six thousand thirty-one kilometres (೩,೭೪೭ 6,031 km (3,747 mi)*)
  • {{convert/spell |6,031|km|mi|case=u}}   → Six thousand thirty-one kilometres (೩,೭೪೭ 6,031 km (3,747 mi)*)
  • {{convert/spell |1/2|ft|cm}}                   → one-half foot (೧೫ 12 ft (15 cm)*)
  • {{convert/spell |1/2|ft|cm|words=out}}   → one-half foot (Lua error in ಮಾಡ್ಯೂಲ್:ConvertNumeric at line ೫೭೫: Invalid decimal numeral. 12 foot (15 centimetres)*)
In many sentences, a conversion is the first part of the sentence, so using Convert/spell can show the first amount spelled in words. Use "case=u" to up-case the first word, spelling with a capital letter. To show both numbers spelled in words, then specify "words=out" as a parameter. See: Template:Convert/spell for more examples. Use {{spellnum}} to show just 1 number in words, such as {{spellnum|23}} → twenty-three.

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 centimetres (6 ft 2 in)
  • {{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}} → 6 feet (180 cm)
  • {{convert|6|ft|cm|disp=u2}} → 6 feet (180 cm)*
  • {{convert|97|km|disp=u2}} → 97 kilometres (60 mi)*
  • {{convert|97|km|disp=u2|abbr=off}} → 97 kilometres (60 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: Many articles use fewer than 8 conversions, formatted in one-quarter second (Convert formats 33 conversions per second). Improvements were made to have Convert run in groups of tiny templates. However, setting the precision (or rounding level) 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 does produce inline tags like: "19 kms[Convert: Unknown unit]". Why?
A: Invalid unit-codes will show error messages. Also, there are some other large templates which consume resources needed when using Convert inside those templates. A common problem is adding an incorrect plural "s" to a unit, such as "km" pluralized to the incorrect "kms" as follows:
  • {{convert|19|km|mi}}     → 19 kilometres (12 mi)
  • {{convert|19|kms|mi}}     → 19 kms[Convert: Unknown unit]
There is no unit kms. Instead unit km should be used, for either 1 or many kilometres.
When other large templates consume all the template resources, then several red messages can appear, such as "Page exceeded the expansion depth" as an alert.
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. However, because Convert can format 15 conversions in a half-second, it is very fast. For numerous conversions, consider hand-coding the results in frequently viewed articles.

Writing new unit-codes[ಬದಲಾಯಿಸಿ]

Q: The unit I need is not in the list, so can I create a unit-code for it?
A: Yes, Convert allows anyone to create a new unit-code in Module:Convert/extra or for Template:Convert/old, to write a new subtemplate, of the form Template:Convert/myunit, to handle a new unit-code named "myunit" by copying another unit subtemplate.
* New unit-codes in Module:Convert/extra are structured data; for examples adding $/g or $/oz, see: dif229).
* 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[ಬದಲಾಯಿಸಿ]

Notes[ಬದಲಾಯಿಸಿ]

  1. During December 2013, {convert} was used in ~554,000 pages, with more than 1.6 million instances, averaging 3 per page.