Шаблон:Convert/док — разлика између измена

Садржај обрисан Садржај додат
Нема описа измене
мНема описа измене
Ред 1:
{{documentation subpage}}{{шаблон на другом писму|вар}}<!--
Template convert aka "tc"transclusions
Statistics on total tc's:
2014-09-05 673940
Ред 8:
2016-05-25 789091
2016-11-17 832994
2017-07-29 872000
2017-12-15 902231
2018-12-27 957770
2019-01-12 960769
2019-01-01 by TDmonthly error report: Page [article] count: 651064; Transclusion count: 2878293
-->
{{hatnote|For currency conversion into US dollars, see [[Template:To USD]]}}
{{#ifeq:{{FULLPAGENAME}}|{{ns:10}}:Convert|{{high-risk| > 1400 }}}}
{{#ifeq:{{FULLPAGENAME}}|Template:Convert|{{high-risk| {{formatnum:960000}}+ }}}}
{{Transwiki guide |small=yes |text=See [[Template:Convert/Transwiki guide|'''this information''']] on copying this template and modifying it for use on another wiki.}}
{{Lua|Module:Convert}}
'''Template {{tl|convert}}''' ''calculates measurements'' from one measurement unit (you can enter) to another one, and then ''presents'' the results formatted. For example:
:<code><nowiki>{{convert|2|km|mi}}</nowiki></code> → {{convert|2|km|mi}} <small>(km entered, so converted into mile)</small>
:<code><nowiki>{{convert|7|mi|km}}</nowiki></code> → {{convert|7|mi|km}} <small>(mi entered, so converted into km)</small>
 
''Numbers'' can be rounded, ''units'' can be abbreviated into symbols:
The available '''units''' are listed [[#Units|below]]. Units are always case-sensitive ({{xt|kW}}, not {{!xt|KW}} or {{!xt|kw}}). Multiple '''formatting''' and calculation options are listed below.
:<code><nowiki>{{convert|2|km|mi|2|abbr=on}}</nowiki></code> → {{convert|2|km|mi|2|abbr=on}}
:<code><nowiki>{{convert|7|mi|km|2|abbr=on}}</nowiki></code> → {{convert|7|mi|km|2|abbr=on}}
Value ''ranges'' can be entered using <code>|to|...</code> or <code>|-|...</code>:
:<code><nowiki>{{convert|2|to|5|km|mi}}</nowiki></code> → {{convert|2|to|5|km|mi}}
:<code><nowiki>{{convert|2|-|5|km|mi}}</nowiki></code> → {{convert|2|-|5|km|mi}}
 
Combined effect example:
{{hatnote|See [[Help:Convert]] for more complete information}}
:<code><nowiki>{{convert|2|-|5|km|mi|2|abbr=on}}</nowiki></code> → {{convert|2|-|5|km|mi|2|abbr=on}}
{{hatnote|For currency conversion into US dollars, see [[Template:To USD]]}}
:<code><nowiki>{{convert|2|and|5|km|mi|sigfig=3|abbr=off}}</nowiki></code> → {{convert|2|and|5|km|mi|sigfig=3|abbr=off}}
 
{{hatnote|See [[Help:Convert]] for more detailed, technical information}}
 
==Units to convert==
{{hatnote|See also: [[Template:Convert/list of units|Complete list of units for {{tlf|Convert}}]]}}
Enter units to convert ''from''&nbsp;''into'':
* <code><nowiki>{{convert|1|lb|kg}}</nowiki></code> → {{convert|1|lb|kg}}
:[[International System of Units|SI]] units generally accept prefixes, like "m" for milli (10<sup>−3</sup>), and "M" for mega (10<sup>6</sup>)
:For "per" units, use "/" (slash): kg/ha
:For three-unit units, etc., see {{cl|Convert-like templates}}
 
==Unit name or symbol (abbreviation): ''1 pound'' or ''1 lb''?==
By default, the first valuequantity shows the unit name spelled out, the second shows the symbol (or abbreviation). Use {{para|abbr|on/off}} to change this behaviour:
* <code><nowiki>{{convert|1|lb|kg}}</nowiki></code> → {{convert|1|lb|kg}}
 
Using {{para|abbr|in}} is the ''reverse behaviour'' to the default:
To abbreviate both:
* <code><nowiki>{{convert|1|lb|kg|abbr=on}}</nowiki></code> → {{convert|1|lb|kg|abbr=on}}
* <code><nowiki>{{convert|1|lb|kg|abbr=off}}</nowiki></code> → {{convert|1|lb|kg|abbr=off}}
 
{{para|abbr|in}} is the reverse behaviour to the default, {{para|abbr|out}}:
*<code><nowiki>{{convert|1|lb|kg|abbr=in}}</nowiki></code> → {{convert|1|lb|kg|abbr=in}}
 
To abbreviate both or neither:
* <code><nowiki>{{convert|1|lb|kg|abbr=on}}</nowiki></code> → {{convert|1|lb|kg|abbr=on}}
* <code><nowiki>{{convert|1|lb|kg|abbr=off}}</nowiki></code> → {{convert|1|lb|kg|abbr=off}}
 
===Convenience: {{tlf|cvt}} has {{para|abbr|on}} by default===
Template {{tl|cvt}} is similarthe tosame as {{tlf|convert}}, butexcept that it has {{para|abbr|on}} as the default behaviour. In {{tlf|cvt}}, all other options are available. So:
:<code><nowiki>{{cvt|1|lb|kg}}</nowiki></code> → {{cvt|1|lb|kg}}
is equalequivalent to:
:<code><nowiki>{{convert|1|lb|kg|abbr=on}}</nowiki></code> → {{cvt|1|lb|kg|abbr=on}}
 
==Adjective: ''a 10-mile distance''==
Use {{para|adj|on}} to produce the adjectiveadjectival (hyphenated) form:
* <code><nowiki>A {{convert|10|mi|km|adj=on}} distance</nowiki></code> → A {{convert|10|mi|km|adj=on}} distance.
Default behaviour, for comparison:
* <code><nowiki>{{convert|10|mi|km}} to go</nowiki></code> → {{convert|10|mi|km}} to go.
 
Even with {{para|abbr|on}}, as per [[MOS:UNITSYMBOLS|Manual of Style]], no hyphen is produced with unit symbols.
This option does not work with {{para|abbr|on}}.
 
=={{anchor|Rounding}}Rounding: ''100 ft'' is ''30&nbsp;m'' or ''30.5&nbsp;m'' or ''30.48&nbsp;m''?==
{{hatnote|See {{section link|Help:Convert#Rounding}} for a more mathematical description of the rounding options}}
By definition, 100&nbsp;ft equals {{convert|100|ft|m|sigfig=4|disp=out}}. In practical use, it is common to round the calculated metric number. With that, there are several possibilities.
 
===Default rounding===
By {{tlf|Convert}} 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 figuresdigits, whichever is more precise. An exception to this is ''rounding temperatures'' (see [[#Rounding temperatures|below]]).
 
{| class="wikitable"
Линија 59 ⟶ 82:
|-
|<code><nowiki>{{convert|123|ft|m|-1}}</nowiki></code> || {{convert|123|ft|m|-1}} ||
|-
|<code><nowiki>{{convert|123|ft|m}}</nowiki></code> || {{convert|123|ft|m}} || same output as with 0 (below)
|-
|<code><nowiki>{{convert|123|ft|m|0}}</nowiki></code> || {{convert|123|ft|m|0}} ||
Линија 64 ⟶ 89:
|<code><nowiki>{{convert|123|ft|m|1}}</nowiki></code> || {{convert|123|ft|m|1}} ||
|-
|<code><nowiki>{{convert|550123|ft|m|02}}</nowiki></code> || {{convert|550123|ft|m|02}} ||The Approximatemore-exact value is 16737.644904 m or so, which gets converted to 37 m if this parameter is not specified at all.
|-
|<code><nowiki>{{convert|500|ft|m|-1}}</nowiki></code> || {{convert|500|ft|m|-1}} ||
|-
|<code><nowiki>{{convert|500|ft|m}}</nowiki></code> || {{convert|500|ft|m}} || 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)
|-
|<code><nowiki>{{convert|500|ft|m|0}}</nowiki></code> || {{convert|500|ft|m|0}} ||
|-
|<code><nowiki>{{convert|500|ft|m|1}}</nowiki></code> || {{convert|500|ft|m|1}} ||
|-
|<code><nowiki>{{convert|500|ft|m|2}}</nowiki></code> || {{convert|500|ft|m|2}} || exact value is 152.4 m
|-
|<code><nowiki>{{convert|550500|ft|mcm|-3}}</nowiki></code> || {{convert|550500|ft|mcm|-3}} || Rounds to 170, when approximate value is 167.64 m
|-
|<code><nowiki>{{convert|500|ft|m|0cm}}</nowiki></code> || {{convert|500|ft|m|0cm}} || Approximatesame valueoutput as with −3 (above), because the conversion factor is 152.4between 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 mused)
|-
|<code><nowiki>{{convert|500|ft|mcm|0}}</nowiki></code> || {{convert|500|ft|mcm|0}} || Rounds to 150, when approximate value is 152.4 m
|}<!--NOTE: rows require "nowiki", using &#123;{ disappears. -->
 
Линија 86 ⟶ 121:
Default behaviour, for comparison:
* <code><nowiki>{{convert|1200|ft|m}}</nowiki></code> → {{convert|1200|ft|m}}
Setting {{para|sigfig|&lt;=0}} to a value less than 1 is meaningless:
* <code><nowiki>{{convert|1200|ft|m|sigfig=0}}</nowiki></code> → {{convert|1200|ft|m|sigfig=0}} {{nay}}
 
===Round to a multiple of 5: ''15'', ''20'', ''25'', ...===
Линија 110 ⟶ 145:
The fraction is reduced when possible:
* <code><nowiki>{{convert|8|cm|in|frac=100}}</nowiki></code> → {{convert|8|cm|in|frac=100}}
Default behaviour, foruses comparisondecimal notation:
* <code><nowiki>{{convert|85.56|cm|in}}</nowiki></code> → {{convert|85.56|cm|in|sigfig=4}}
 
==={{anchor|Rounding temperatures}}InRounding temperatures: rounding ''°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}}
Линија 120 ⟶ 155:
#{{#invoke:DemoTemplate|convert|-272|C|F K}}
#{{#invoke:DemoTemplate|convert|-272|C}}
#{{#invoke:DemoTemplate|convert|-300100|C|F K}}
#{{#invoke:DemoTemplate|convert|0|C|F K}}
 
Линија 129 ⟶ 164:
:{{#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 into five significant output digits because of the two numbersdigits 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 {{tlc|&#35;expr:}} 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:
* {{para|adj|ri0}}
* {{para|adj|ri1}}
* {{para|adj|ri2}}
* {{para|adj|ri3}}
Note that there is no {{para|adj|ri-1}}{{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:
* {{tlc|convert|4.14159|mi|km|adj{{=}}ri0}} → {{convert|4.14159|mi|km|adj=ri0}} {{nay}} (precisions are mismatched)
* {{tlc|convert|4.14159|mi|km|0|adj{{=}}ri0}} → {{convert|4.14159|mi|km|0|adj=ri0}} {{aye}}
 
In this case, if the input were rounded before conversion, a different result would be obtained:
* {{tlc|convert|<nowiki>{{#expr:4.14159 round 0}}</nowiki>|mi|km|0}} → {{convert|{{#expr:4.14159 round 0}}|mi|km|0}} {{nay}} (double rounding)
 
==Into multiple units: ''{{convert|10|C|F K}}''==
Линија 138 ⟶ 190:
 
See also:
* For multiple-unit options like ''1 ft 5 in'', see [[#{{section link||In input]]}} and [[#{{section link||In output]]}}.
 
==Ranges of values==
Линија 157 ⟶ 209:
In science, the formal way is to set <code>&#x7c;x&#x7c;</code> and {{para|abbr|on}} (keeping dimensions right, like in ''area = x km<sup>2</sup>''):
* <code><nowiki>{{convert|6|x|12|m|ft|abbr=on}}</nowiki></code> → {{convert|6|x|12|m|ft|abbr=on}}
 
===Lists of values: ''20, 40, or 60 miles''===
:<code><nowiki>{{convert|20|,|40|, or|60|mi}}</nowiki></code> &rarr; {{convert|20|,|40|, or|60|mi}}
 
===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:
* <code><nowiki>{{convert|1|ft|3|in|x|3|ft|5|in|mm}}</nowiki></code> → {{convert|1|ft|3|in|x|3|ft|5|in|mm}} {{nay}}
Default behaviour, for comparison:
* <code><nowiki>{{convert|1|ft|3|in|mm}}</nowiki></code> → {{convert|1|ft|3|in|mm}}
Линија 170 ⟶ 225:
:<code><nowiki>{{convert|1|m|ft|sp=us}}</nowiki></code> → {{convert|1|m|ft|sp=us}}
 
===<span id="spell"></span>Spell out numbers: ''ten miles''===
To write a number in words, use {{para|spell|in}}:
* <code><nowiki>{{convert|10|mi|m|spell=in}}</nowiki></code> → {{convert|10|mi|m|spell=in}}
Линија 191 ⟶ 246:
 
===After adjective unit: ''A {{convert|10|ft|ft|adj=mid|-long|disp=out|order=flip}} corridor''===
Note that two units (in this case, ft and m) are required. Use with just one unit will generate an error message.
:<code><nowiki>{{convert|10|ft|m|adj=mid|-long}}</nowiki></code> → {{convert|10|ft|m|adj=mid|-long}}
 
Линија 205 ⟶ 261:
===Fractions: ''one-eighth of an imperial pint''===
The convert template also supports spelling out fractions.
* <code><nowiki>{{convert|3+1/42|oz|g|spell=in}}</nowiki></code> → {{convert|3+1/42|oz|g|spell=in}}
Any additional words needed for the fraction can also be added at the end of the template.
* <code><nowiki>{{convert|1/8|imppt|mLml|spell=in|adj=pre|of an}}</nowiki></code> → {{convert|1/8|imppt|mLml|spell=in|adj=pre|of an}}
<!-- todo: decimals & negative examples -->
 
===Wrapping and line breaking===
:See {{section link|Help:Convert|Wrapping and line breaking}}
 
===<span id="million"></span>Spelling out "thousands", "millions", etc.===
Most unit codes accept a prefix of e3 (thousand) or e6 (million) or e9 (billion).
* <code><nowiki>{{convert|100|e6mi|e6km}}</nowiki></code> → {{convert|100|e6mi|e6km}}
* <code><nowiki>{{convert|120|e6acre}}</nowiki></code> → {{convert|120|e6acre}}
* <code><nowiki>{{convert|120|e6acre|e3km2}}</nowiki></code> → {{convert|120|e6acre|e3km2}}
 
To display both input and output in scientific notation, use {{para|abbr|on}}
* <code><nowiki>{{convert|100|e6mi|e6km|abbr=on}}</nowiki></code> → {{convert|100|e6mi|e6km|abbr=on}}
 
To spell out "thousands", "millions", etc., {{para|abbr|unit}} abbreviates the unit; {{para|abbr|off}} displays both full unit names.
* <code><nowiki>{{convert|100|e6mi|e6km|abbr=unit}}</nowiki></code> → {{convert|100|e6mi|e6km|abbr=unit}}
* <code><nowiki>{{convert|100|e6mi|e6km|abbr=off}}</nowiki></code> → {{convert|100|e6mi|e6km|abbr=off}}
 
==Numbers==
 
===Using an SI prefix: ''gigameter (Gm)'', or ''micrometer (μm&#x03BC;m)''===
{{Sidebar metric prefixes (small)}}
Units can have an [[metric prefix|SI prefix]] like <code>G</code> before the unit: <code>Gm</code>, and <code>giga</code> before the name: <code>gigameter</code>. These are plain multiplication factors.
Линија 225 ⟶ 297:
* <code>km</code>: {{convert|12|km|ft|abbr=on}}
* <code>mm</code>: {{convert|12|mm|in|abbr=on}}
* <code>μm&#x03BC;m</code>: {{convert|12|μm|mm|abbr=on}}
* <code>um</code>: {{convert|12|um|mm|abbr=on}} (letter "u" can be used for "μ&#x03BC;" here)
 
The prefix can be used in the output unit:
Линија 232 ⟶ 304:
* <code><nowiki>{{convert|12|in|μm|abbr=on}}</nowiki></code> → {{convert|12|in|μm|abbr=on}}
 
As an exception, the non-SI unit "inch" can have the "μ&#x03BC;" prefix too)
* <code><nowiki>{{convert|12|μm&#x03BC;m|μin|abbr=on}}</nowiki></code> → {{convert|12|μm|μin|abbr=on}}
 
{{further information|Help:Convert units#SI prefixes}}
Линија 240 ⟶ 312:
 
====In the unit: ''e6m''====
[[Engineering notation|Engineering number notations]] like ''7{{smallcaps|E}}6'' (for 7 × 10<sup>6</sup>) can be entered as a "prefix" to the unit:
* <code><nowiki>{{convert|770|e6m}}</nowiki></code> → {{convert|770|e6m|abbr=on}}
 
The same is possible for the output unit:
Линија 253 ⟶ 325:
* <code>e15</code> (quadrillion).
 
===Scientific notation: ''1.23×1023 × 10<sup>−14</sup>''===
In [[scientific notation]], a number is written like {{rnd|12.3e-15|16}}. The plain number has exactly one digit before the decimal point.
 
Линија 265 ⟶ 337:
*<code><nowiki>{{convert|1⁄2|in|mm|1}}</nowiki></code> → {{convert|1⁄2|in|mm|1}}
 
With integerspositive [[mixed number]]s (a positive integer and a fraction), use a <code>+</code> sign
*<code><nowiki>{{convert|2+1⁄2|in|mm|1}}</nowiki></code> → {{convert|2+1⁄2|in|mm|1}}
 
WhenWith negative mixed numbers, use a hyphen <code>-</code> and repeat it:
*<code><nowiki>{{convert|-2-1⁄2|in|mm|1}}</nowiki></code> → {{convert|-2-1⁄2|in|mm|1}}
 
*<code><nowiki>{{convert|2-1⁄2|in|mm|1}}</nowiki></code> → {{convert|2-1⁄2|in|mm|1}} Note: this is read as a range
Note that the following cases are not interpreted as mixed numbers:
*<code><nowiki>{{convert|-2+1⁄2|in|mm|1}}</nowiki></code> → {{convert|-2+1⁄2|in|mm|1}} {{nay}} Should be a number, not an expression (do not require a calculation)
*<code><nowiki>{{convert|2-1⁄2|in|mm|1}}</nowiki></code> → {{convert|2-1⁄2|in|mm|1}}. This is interpreted as a range from 2 inches to 1⁄2 inch.
*<code><nowiki>{{convert|-2+1⁄2|in|mm|1}}</nowiki></code> → {{convert|-2+1⁄2|in|mm|1}} {{nay}} This is neither a mixed number nor a range, and mathematical expressions requiring calculations are not allowed here.
 
===Output with horizontal fraction bar in: ''{{sfrac|1|2}}&nbsp;inch''===
Линија 293 ⟶ 367:
* <code><nowiki>{{convert|1234567|m|ft}}</nowiki></code> → {{convert|1234567|m|ft}}
 
Setting {{para|comma|5}} or {{para|comma|gaps5}} will only add the separator when the number of digits is 5 or more:
* <code><nowiki>{{convert|1234|m|ft|comma=5}}</nowiki></code> → {{convert|1234|m|ft|comma=5}}
* <code><nowiki>{{convert|1234567|m|ft|comma=5}}</nowiki></code> → {{convert|1234567|m|ft|comma=5}}
* <code><nowiki>{{convert|1234|m|ft|comma=gaps5}}</nowiki></code> → {{convert|1234|m|ft|comma=gaps5}}
* <code><nowiki>{{convert|1234567|m|ft|comma=gaps5}}</nowiki></code> → {{convert|1234567|m|ft|comma=gaps5}}
Default behaviour, for comparison:
* <code><nowiki>{{convert|1234|m|ft}}</nowiki></code> → {{convert|1234|m|ft}}
Линија 314 ⟶ 386:
* <code><nowiki>{{convert|10|m|ft|disp=br}}</nowiki></code> → {{convert|10|m|ft|disp=br}}
 
Also {{para|disp|br()}} will force a new line, and keep the brackets (useful in tables):
* <code><nowiki>{{convert|10|m|ft|disp=br()}}</nowiki></code> → {{convert|10|m|ft|disp=br()}}
 
Setting {{para|disp|x{{!}}…}} allows any text as separator:
* <code><nowiki>{{convert|10|m|ft|disp=x|_MyText_}}</nowiki></code> → {{convert|10|m|ft|disp=x|_MyText_}} <small>(To display spaces, use <code>&amp;nbsp;</code>)</small>
<!--todo: works for multiple freetexts too! |disp=x|TextA|TextB -->
 
===<span id="flip"></span>Flipping (reordering) the two measurements: ''{{convert|1|mi|m|order=flip|sigfig=5|abbr=off}}'' ===
Setting {{para|order|flip}} will flip (swap) the two measurements:
* <code><nowiki>{{convert|1|mi|m|order=flip}}</nowiki></code> → {{convert|1|mi|m|order=flip|sigfig=5|abbr=off}}<!-- Extra settings added to enhance the illustration. Don't know if this is ideal way of documenting. DePiep, August 2014. --></small>
Default behaviour, for comparison:
* <code><nowiki>{{convert|1|mi|m}}</nowiki></code> → {{convert|1|mi|m|sigfig=5|abbr=off}}
Линија 329 ⟶ 402:
* <code><nowiki>{{convert|10|km|mi nmi|order=flip}}</nowiki></code> → {{convert|10|km|mi nmi|order=flip|sigfig=5|abbr=off}}
* <code><nowiki>{{convert|10|km|nmi mi|order=flip}}</nowiki></code> → {{convert|10|km|nmi mi|order=flip|sigfig=5|abbr=off}}
 
===Fixed ordering of output units: ''{{convert|100|C|F C K|abbr=on|order=out}}'' ===
Setting {{para|order|out}} shows the output-units as ordered; the input unit is skipped:
*<code><nowiki>{{convert|100|C|F C K|abbr=on|order=out}}</nowiki></code> &rarr; {{convert|100|C|F C K|abbr=on|order=out}}
*<code><nowiki>{{convert|200|PS|kW hp|0|abbr=on|order=out}}</nowiki></code> → {{convert|200|PS|kW hp|0|abbr=on|order=out}}
 
''See also: [[Template:Convert#Displaying_parts_of_the_result:_2_(1.5)|§ Displaying parts of the output]]''.
 
=== Displaying parts of the result: ''{{convert|2|cuyd|m3|abbr=values}}''===
Линија 335 ⟶ 415:
 
{| class="wikitable"
! Convert !! Output !! DescriptionReturns
|-
| <code><nowiki>{{convert|2|cuyd|m3}}</nowiki></code> || {{convert|2|cuyd|m3}}
| DefaultRegular behaviour,output (for comparison)
|-
| <code><nowiki>{{convert|2|cuyd|m3|abbr=values}}</nowiki></code>
Линија 349 ⟶ 429:
| Input unit, adjective (hyphenated)
|-
| <code><nowiki>{{convert|2|cuyd|cuyd|0|disp=out|abbr=off}}</nowiki></code> || {{convert|2|cuyd|cuyd|0|disp=out|abbr=off}} || Input (''workaround''. {{nowrap|1=Note repetition of unit in input}})
|-
| <code><nowiki>{{convert|2|cuyd|m3|abbr=~}}</nowiki></code> || {{convert|2|cuyd|m3|abbr=~}}
Линија 362 ⟶ 442:
|-
| <code><nowiki>{{convert|2|cuyd|m3|disp=out}}</nowiki></code> || {{convert|2|cuyd|m3|disp=out}}
| Output value and unit name
|-
| <code><nowiki>{{convert|2|cuyd|m3|disp=out|abbr=off}}</nowiki></code> || {{convert|2|cuyd|m3|disp=out|abbr=off}}
| Output value and unit symbol
|}
 
Линија 393 ⟶ 473:
 
{{para|disp|tablecen}} does the same, and also centers the text:
:<code><nowiki>{{convert|20|m|ft|disp=tablecen}}</nowiki></code> →
::<code>{{convert|20|m|ft|disp=tablecen}}</code>
 
Линија 414 ⟶ 494:
===Sorting===
Use {{para|sortable|on}} to include a ''hidden numerical sortkey'' in the output, suitable for use in a [[Help:Sorting|table with sortable columns]]. Technically, this places a hidden string before the actual displayed values:
:<code><nowiki>{{convert|10|m|ft|sortable=on}}</nowiki></code> {{nowrap|1=→ <code>&lt;span style="display:none">}}7001100000000000000<wbr /class="sortkey">7001100000000000000♠&lt;/span>10 metres (33&amp;nbsp;ft)</code>}}
:showing: {{convert|10|m|ft|sortable=on}}.
 
Use both {{para|disp|table}} and {{para|sortable|on}} together to produce table columns (pipe symbols) for each value in sortable columns:
Линија 439 ⟶ 520:
 
==Units==
The conversion factors and physical constants are sourced [[Module:Convert/documentation/conversion data introduction/doc#Conversion factors and physical constants|here]].
 
===All units===
{{selfref|See also: [[Template:Convert/list of units|Convert/list of units]]}}
Линија 446 ⟶ 529:
</div>
 
==={{anchor|per}}'per' units: ''kg/hl'', ''miles per gallon''===
When using a slash (<code>/</code>), a unit like <code>kg/hl</code> is recognized as kilograms ''per'' hectolitre and will be converted with other mass/volume units.
* <code><nowiki>{{convert|1000|kg/hl}}</nowiki></code> → {{convert|1000|kg/hl}}
 
Population density (''inhabitants per square mile'') can be converted using
==={{anchor|Units of difference}}Units of difference: ''10&nbsp;&deg;C higher; how much in &deg;F''===
* <code><nowiki>{{convert|10|PD/sqmi|PD/sqkm}}</nowiki></code> → {{convert|10|PD/sqmi|PD/sqkm}}
When a number is the measurement for a ''difference'', one conversion is done. This may occur in temperatures (°C, °F, K). Compare this to a ''range'', when two conversions are done.
 
Vehicular fuel efficiency, commonly expressed in ''miles per gallon'' or ''litres per 100 km'' can also be converted
* <code><nowiki>{{convert|26|mpgUS|l/100km mpgimp}}</nowiki></code> → {{convert|26|mpgUS|l/100km mpgimp}}
 
==={{anchor|Units of difference}}Units 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&nbsp;°C"), or when ''comparing'' temperatures (e.g., "10 to 15&nbsp;°C ''warmer''"), we cannot use the standard temperature units ({{para||C}}, {{para||F}} and {{para||K}}), which refer to points on the respective scale. Instead, we must use one of the following "units of difference": {{para||C-change}}, {{para||F-change}} and {{para||K-change}}.
 
Compare the following two examples with the two above:
 
* {{#invoke:DemoTemplate|convert|10|C-change}} increase in temperature
The only available units of difference are: {{para|C-change}}, {{para|F-change}} and {{para|K-change}}.
* {{#invoke:DemoTemplate|convert|1010–15|C-change}}, regularwarmer temperaturethan normal
* {{#invoke:DemoTemplate|convert|10|C-change}}, difference (e.g., "The temperature changed from 30 into 40 °C")
* {{#invoke:DemoTemplate|convert|10-15|C}}, range (e.g., "The temperature is between 10 and 15 °C")
 
Consistently,To intoproduce multiple units in the output:
* <code><nowiki>A rise of {{#invoke:DemoTemplate|convert|10|C-change|F-change K-change}}</nowiki></code> → A rise of {{convert|10|C-change|F-change K-change}}difference
 
===Multiple units: ''1 ft 5 in''===
Линија 483 ⟶ 576:
Using currency symbols in a ''$ per unit'' value, you can convert the per-unit:
* <code><nowiki>{{convert|10|$/mi|$/km}}</nowiki></code> → {{convert|10|$/mi|$/km}}
* <code><nowiki>{{convert|1500|$/ozt|$/g}}</nowiki></code> → {{convert|1500|$/ozt|$/g}}
 
You can set the currency in ''both'' values using {{para|$|€}}:
Линија 488 ⟶ 582:
 
It is ''not'' possible to convert the currency. So, this result (mixed currencies) is ''not'' possible: {{!mxt|1=$15 per mile (€8.6/km)}} {{nay}}
 
==Using convert inside templates==
For usage in template code, like infoboxes, {{tlf|Convert}} has these options:
;Pre-formatting fraction input
* [[Module:Convert/helper]] can read regular input and pre-format it into {{tlf|Convert}}-accepted input.
:Your template can accept {{para|input|16 7/8}} and use <nowiki>{{#invoke:Convert/helper|number|16 7/8}}</nowiki> &rarr; {{#invoke:Convert/helper|number|16 7/8}}
 
;Using a Wikidata property
* Adding the Wikidata property code, like code {{para|input|P2073}}, 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 {{para|qid}}.
 
Example for {{Wikidata property link|P2073}}:
Note: this example uses {{para|qid|Q1056131}} (testing for {{Wikidata entity link|Q1056131}})
* <code><nowiki>{{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}</nowiki></code> &rarr; {{convert|input=P2073|qid=Q1056131|ftin|abbr=on}}
* <code><nowiki>{{convert|input=P2073|qid=Q1056131|km|abbr=on}}</nowiki></code> &rarr; {{convert|input=P2073|qid=Q1056131|km|abbr=on}}
* <code><nowiki>{{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}</nowiki></code> &rarr; {{convert|input=P2073|qid=Q1056131|km|abbr=on|disp=out}}
:For example see [[template:Infobox Telescope]].
 
==Parameter list==
Линија 500 ⟶ 611:
<templatedata>
{
"description": "ОвајConverts шаблонmeasurements претвараto једнуother јединицу у другуunits.",
"params": {
"1": {
"label": "ВредностValue",
"description": "ВредностThe заvalue претварањеto convert.",
"type": "number",
"aliasesrequired": [true
"value"
],
"example": "132",
"required": true,
"suggested": true
},
"2": {
"label": "ОдFrom јединицеunit",
"description": "ЈединицаThe којаunit ћеfor битиthe пребаченаprovided у другуvalue.",
"type": "string/line",
"aliases": [
"to unit"
],
"example": "km",
"required": true,
"suggested": 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.",
"description": "Јединица у коју ће се пребацивати.",
"type": "string",
"aliasesexample": ["mi nmi",
"to unit",
"in unit"
],
"example": "mi",
"required": true,
"suggested": true
},
"4": {
"label": "precisionPrecision or suffix",
"description": "significantSignificant digits after decimal dot or, if negative, exponent of ten.",
"type": "number"
},
"lk": {
"label": "linkLink 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” nofor none of the units.",
"default": "off",
"type": "string/line",
"example": "on"
},
"abbr": {
"label": "abbreviationAbbreviation",
"description": "displayDisplay for the units: “on” to display all units using their unit symbols, “off” allto unitdisplay namesall units in full words, “in” inputto display the unit symbol for the input unit, “out” abbreviatedto 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/line",
"example": "on, unit, in, out, off",
"suggested": true
},
"sp": {
"label": "spellingSpelling",
"description": "Spelling of units. Use “us” to display unit names using U.S. spelling of unit names.",
"type": "string/line",
"example": "us"
},
"adj": {
"label": "adjectiveAdjective",
"description": "adjectiveWhether to use adjectival form. Use “on” for (singular unit name appended by a hyphen) “on” or, “mid” to put conversion at end, or “off” (default) for no adjectival form.",
"type": "string/lineboolean",
"example": "on",
"default": "off"
},
"disp": {
"label": "conversionConversion",
"description": "displayDisplay 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.",
"defaulttype": "bstring",
"typeexample": "string/lineb",
"deprecated": "use order=flip instead"
},
"order": {
"label": "orderingOrdering",
"description": "“flip” returns converted value first, input value second.",
"type": "string/line",
"example": "flip"
},
"sigfig": {
"label": "significantSignificant figures",
"description": "number that setsIndicates the number of significant figures to be used in rounding.",
"type": "number"
},
"round": {
"label": "roundingRounding 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": "string/linenumber"
},
"comma": {
"label": "thousandsThousands separator",
"description": "Sets or suppresses thousandthe separatoruse of thousands separators in the numbers. “off” =: no separator; “gaps”: use space notinstead of comma as thousands separator; “5” and “gaps5”: 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/line",
"example": "off"
},
"sortable": {
"label": "sortSort key",
"description": "“on” generates a hidden sort key",
"type": "string/line",
"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": "Reeds the property value of the item (article), then converts it",
"example": "{{convert|input=P2046}} (P2046=area)",
"type": "string"
}
},
"format": "inline"
}
</templatedata>
Линија 612 ⟶ 750:
<noinclude>
[[Category:Convert by module documentation| ]]
</noinclude><includeonly>{{#ifeq:{{SUBPAGENAME}}|докdoc||
[[Category:Convert templates| ]]
[[Category:Conversion templates]]