Templat:Convert/doc: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
k doc |
k Robot: Perubahan kosmetika |
||
Baris 10:
-->
{{#ifeq:{{FULLPAGENAME}}|Template:Convert|{{high-risk| 745,000+ }}}}
{{Transwiki guide |small=yes |text=See [[
{{Lua|Module:Convert}}
'''Template {{tl|convert}}''' ''calculates'' measurements from one unit (you can enter) to another one, and then ''presents the results''. For example:
Baris 18:
The available '''units''' are listed [[#Units|below]]. Units are case-sensitive always ({{xt|kW}}, ''not'' {{!xt|KW}} and ''not'' {{!xt|kw}}). Multiple '''formatting''' and calculation options are listed below.
{{hatnote|See also [[
== Unit name or symbol (abbreviation): ''1 pound'' or ''1 lb''? ==
By default, the first value shows unit name, the second the symbol (or abbreviation).
Use {{para|abbr|on/off}} to change this behaviour:
Baris 29:
:<code><nowiki>{{convert|1|lb|kg|abbr=in}}</nowiki></code> → {{convert|1|lb|kg|abbr=in}}
== Adjective: ''a 10-mile distance'' ==
Use {{para|adj|on}} to produce the adjective form. The difference:
:<code><nowiki>{{convert|10|mi|km}} to go</nowiki></code> → {{convert|10|mi|km}} to go. ''(To compare, default)''
Baris 35:
This option does not work with {{para|abbr|on}}.
== Rounding: ''100 ft'' is ''30 m'' or ''30.5 m'' or ''30.48 m''? ==
By definition, 100 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 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 figures, whichever is more precise. An exception to this is ''rounding temperatures'' (see [[#Rounding temperatures|below]]).
Baris 64:
''Convert'' supports four types of rounding:
=== Round to a given precision: ''use {{para|precision|}}'' ===
Specify the desired precision with the fourth unnamed parameter (or third unnamed parameter if the "convert to" parameter is omitted; or fifth unnamed parameter if a range is specified; or fourth unnamed parameter again if a range is specified and the "convert to" parameter is omitted; needs to be replaced with a "precision" named parameter). The conversion is rounded off to the nearest power of {{frac|10}} this number. For instance, if the result is 8621 and the round number is "-2", the result will be 8600. If the result is "234.0283043" and the round number is "0", the result will be 234.
=== Round to a given number of significant figures: ''{{para|sigfig|}}'' ===
To specify the output number to be with ''n'' significant figures use {{para|sigfig|<number>}}:
* <small>To compare:</small> <code><nowiki>{{convert|1200|ft|m}}</nowiki></code> → {{convert|1200|ft|m}}
Baris 77:
* <code><nowiki>{{convert|1200|ft|m|sigfig=0}}</nowiki></code> → {{convert|1200|ft|m|sigfig=0}}
=== Round to a multiple of 5: ''15'', ''20'', ''25'', ... ===
Using {{para|round|5}} rounds the outcome to a multiple of 5.
:<code><nowiki>{{convert|10|m|ft}}</nowiki></code> → {{convert|10|m|ft}}
Baris 91:
:<code><nowiki>{{convert|10 x 200 x 3000|m|ft|round=each}}</nowiki></code> → {{convert|10 x 200 x 3000|m|ft|round=each}}
=== Round to a multiple of a given fraction: ''{{frac|2|3|16}} inch'' ===
Specify the desired ''denominator'' using {{para|frac|<some positive integer>}}. ([[Fraction (mathematics)|Denominator]] is the below-the-slash number, for example the 3 in {{frac|1|3}}).
:<code><nowiki>{{convert|5.56|cm|in|frac=16}}</nowiki></code> → {{convert|5.56|cm|in|frac=16}}
Baris 99:
:<code><nowiki>{{convert|8|cm|in}}</nowiki></code> → {{convert|8|cm|in|sigfig=4}} (To compare)
=== {{anchor|Rounding temperatures}}In temperatures: rounding ''°C'', ''°F'' and ''K'' ===
In temperatures, the conversion will be rounded either to 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.
Baris 115:
:{{#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.)
== Into multiple units: ''{{convert|10|C|F K}}'' ==
Separate the multiple output units by a space:
:<code><nowiki>{{convert|10|C|F K}}</nowiki></code> → {{convert|10|C|F K}}
Baris 125:
For multiple-unit options like ''1 ft 5 in'', see [[#In input]] and [[#In output]].
== Ranges of values ==
{{For|a conversion of a difference|#Units of difference}}
A ''range'' converts ''two'' values and separates them by your choice of words and punctuation.
=== A range: ''6 to 17 kg (13 to 37 lb)'' ===
Range indicators are entered as the second parameter (between the values). Range separators can be:<br />
{{Convert/doc/range separator list}}
Baris 142:
:<code><nowiki>{{convert|6|x|12|m|ft|abbr=on}}</nowiki></code> → {{convert|6|x|12|m|ft|abbr=on}}
=== 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|mm}}</nowiki></code> → {{convert|1|ft|3|in|mm}} <small>(to compare)</small>
* <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}}
== Words ==
=== Spelling of unit name: UK ''metre'' or US ''meter''? ===
Default spelling of units is en-UK. To show en-US spelling, use {{para|sp|us}}:
:<code><nowiki>{{convert|1|m|ft}}</nowiki></code> → {{convert|1|m|ft}}—''default''
:<code><nowiki>{{convert|1|m|ft|sp=us}}</nowiki></code> → {{convert|1|m|ft|sp=us}}
=== 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}}
Baris 166:
Remember that the spelling of the units (ft, m) is independently set by {{para|abbr|}}. To the extreme:
:<code><nowiki>{{convert|10|mi|m|spell=on|abbr=off|sp=us}}</nowiki></code> → {{convert|10|mi|m|spell=on|abbr=off|sp=us}}
=== Extra words: ''4 planted acres'' ===
:''Incomplete section''
:<code><nowiki>{{convert|4|acre||adj=pre|planted}}</nowiki></code> → {{convert|4|acre||adj=pre|planted}}
Baris 173:
:<code><nowiki>{{convert|4|ft|m|adj=mid|-long}}</nowiki></code> → {{convert|10|ft|m|adj=mid|-long}}
=== Plurals: ''1 inch, 2 inches'' ===
The unit symbol is singular always. Depending on the preceding number only, a unit name can be shown plural.
* <code><nowiki>{{convert|1|metre}}</nowiki></code> → {{convert|1|metre}}
Baris 183:
* <code><nowiki>{{convert|100|foot|abbr=off}}</nowiki></code> → {{convert|100|foot|abbr=off}}
=== Extreme changes for grammatical structure: ''The 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons'' ===
This example is from the article [[Fort McHenry#
{{quotation|The American defenders had 18-, 24- and 32-pounder (8, 11 and 15 kg) cannons.}}
You can't get this sentence structure as a direct result of using {{tlf|convert}} and its options. However, you can get the correctly converted numbers ''and'' the grammatical structure you want to use by using {{tlf|convert}} ''plus'' three stages of editing, previewing and saving versions of the text you wish to change.
Baris 225:
* <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 "μ" prefix
* <code><nowiki>{{convert|12|μm|μin|abbr=on}}</nowiki></code> → {{convert|12|μm|μin|abbr=on}}
:{{further|Help:Convert units#SI prefixes}}
=== Engineering notation: ''7 × 10<sup>6</sup> m'' ===
==== 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|7|e6m}}</nowiki></code> → {{convert|7|e6m}}
Baris 240:
:<code>e3</code> (thousand), <code>e6</code> (million), <code>e9</code> (billion), <code>e12</code> (trillion), <code>e15</code> (quadrillion).
=== Scientific notation: ''1.23×10<sup>−14</sup>'' ===
In [[scientific notation]], a number is written like {{rnd|12.3e-15|16}}.
Baris 248:
:*<code><nowiki>{{convert|0.00000005|atm|atm|abbr=on}}</nowiki></code> → {{convert|0.00000005|atm|atm|abbr=on}}
=== Input with fractions: ''{{convert|1+1/2|in|mm|1}}'' ===
The number to convert can be written in fractions. Both <code>/</code> (keyboard slash) and <code>⁄</code> (fraction slash) are accepted:
:<code><nowiki>{{convert|1/2|in|mm|1}}</nowiki><code> → {{convert|1/2|in|mm|1}}
Baris 259:
:<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)
=== Output with horizontal fraction bar in: ''{{sfrac|1|2}} inch'' ===
<!-- techinical restriction: TOC does not show the example horizontal bar intended here; rephrased section title-->
Using a double slash (<code>//</code>) returns a horizontal bar fraction:
Baris 265:
* <code><nowiki>{{convert|2+1//2|in|mm|1}}</nowiki></code> → {{convert|2+1//2|in|mm|1}}
=== Thousands separator: ''1,000 mi'' or ''1000 mi'' ===
In input, a comma for thousands separator is accepted but not required; a gap (space) is not accepted. In output, by default, the thousand separator is the comma:
*<code><nowiki>{{convert|1234567|m|ft}}</nowiki></code> → {{convert|1234567|m|ft}}
Baris 286:
== Output manipulation ==
=== Brackets and separators: ''10 m [33 ft]'' ===
Punctuation that distinguishes the two measurements is set by {{para|disp|}}.<br />
Options are: <code>b</code> <small>(the default)</small>, <code>sqbr</code>, <code>comma</code>, <code>or</code>, <code>br</code>, <code>x{{!}}...</code>:
Baris 349:
| Output value and unit
|}
=== Display input name and symbol: ''2 kilopascals [kPa]'' ===
Setting {{para|abbr|~}} returns both name and
:<code><nowiki>{{convert|2|kPa|psi|abbr=~}}</nowiki></code> → {{convert|2|kPa|psi|abbr=~}}
:<code><nowiki>A {{convert|2|kPa|psi|abbr=~|adj=on}} pressure</nowiki></code> → {{nowrap|A {{convert|2|kPa|psi|abbr=~|adj=on}} pressure}}
== Table options ==
For the [[
=== Enforced line break ===
{{para|disp|br}} adds a line-break and omits brackets.
Baris 392:
=== Sorting ===
Use {{para|sortable|on}} to include a ''hidden numerical sortkey'' in the output, suitable for use in a [[
:<code><nowiki>{{convert|10|m|ft|sortable=on}}</nowiki></code> → {{nowrap|1=<span style="display:none">7001100000000000000</span>10 metres (33&nbsp;ft)}}
Baris 417:
The generated sortkey is calculated in a consistent way based on both the value and its unit as passed to the convert template. In most cases convert uses the passed value converted to SI base units. It is therefore not necessarily the displayed value or other alternate units and is calculated regardless of output format options. Using different units or different order of units in individual rows should therefore not lead to incorrect sorting, although variations in rounding can give surprising results, since an unrounded number is used for the sortkey.
== Units ==
=== All units ===
{{selfref|See also: complete [[
{{hatnote|Units are case-sensitive: use {{xt|kW}}, not {{!xt|KW}} or {{!xt|kw}}}}
<div style="height: 400px; overflow: auto; padding: 3px; border: 1px solid #aaa;">
Baris 425:
</div>
=== 'per' units: ''kg/hl'' ===
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}}
=== Units of difference ===
When a number is the measurement for a ''difference'', one conversion is done.
:{{#invoke:DemoTemplate|convert|10|C}}
Baris 439:
The only available units of difference are: {{para|C-change}}, {{para|F-change}} and {{para| K-change}}.
=== Multiple units: ''1 ft 5 in'' ===
==== In input ====
Base document [[
::*<code><nowiki>{{convert|1|yd|2|ft|3|in}}</nowiki></code> → {{convert|1|yd|2|ft|3|in}}
::*<code><nowiki>{{convert|2|ft|3|in|cm}}</nowiki></code> → {{convert|2|ft|3|in|cm}}
::*<code><nowiki>{{convert|1|lb|5|oz|g}}</nowiki></code> → {{convert|1|lb|5|oz|g}}
==== In output ====
Available multiple-unit output options predefined, like <code>ftin</code> and <code>ydftin</code>. The full list is at [[
:*<code><nowiki>{{convert|2|m|ftin}}</nowiki></code> → {{convert|2|m|ftin}}
:*<code><nowiki>{{convert|2|m|ft in}}</nowiki></code> → {{convert|2|m|ft in}}—using a space, returns the decimal point
Baris 457:
<!-- todo: mention the 0-3 limits -->
=== Currency per unit: ''$/mi, $/km'' ===
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}} {{aye}}
:You can set the unit in ''both'' values using {{para|$|€}}:
:* <code><nowiki>{{convert|10|$/mi|$/km|$=€}}</nowiki></code> → {{convert|10|$/mi|$/km|$=€}}
You can ''not'' convert the currency. This outcome combination is ''not'' possible: {{!mxt|1=$15 per mile (€8.6/km)}}
== Parameter list ==
{{convert/doc/parameter list}}
== Deprecated options ==
{{Convert/doc/deprecations list}}
== TemplateData ==
{{TemplateDataHeader}}
|