![]() | Predloga se uporablja na številnih straneh, zato bo vsaka njena sprememba takoj zelo opazna. Prosimo, da vse spremembe, ki jih želite uvesti, pred uvedbo preizkusite na podstraneh predloge (/peskovnik in /testniprimeri) ali na svojih lastnih podstraneh. Pred spreminjanjem te predloge se o želenih spremembah rajši pogovorite na pogovorni strani. |
![]() | Uporablja Lua: |
![]() | Prosimo, da vnesete vse numerične vrednosti, ki vsebujejo tudi decimalko, z decimalno vejico. |
This template is used to easily present values in scientific notation, including uncertainty and/or units, as prescribed by Wikipedia's Manual of Style.
Val specializes in numeric values, especially those with scientific notations, uncertainty notations, and those with measurement values with physical units. Because these expressions are covered by the Manual of Style, Val provides the stylized output for you, and keeps them from wrapping across lines.
Express a numeral:
{{val|123456,78901}}
→ value, formatted with gaps: 123456,78901, or with |fmt=dots
→ 1.234,5678901.{{val|number|number}}
→ value ± uncertainty, like 123.478±56{{val|number|(number)}}
→ value(uncertainty), like 12.345(56).{{val|number|number|number}}
→value +uncertaintyExpress a measurement value: {{val|4|ul=m2}}
→ 4 m2. The m2 is a "unit code" that Val uses to lookup the link to the unit's article, and the formatting of the unit symbol. Val links the units to the page it has on file for them. See {{Val/list}}.
There are a large number of unit codes that Val understands and keeps "up to code". A unit code is the just abbreviated unit name, but these can get quite involved for a compound or composite unit, with "multipliers" or "dividers". See Module:Val/units.
Some unit-code flexibility is provided by having four parameters to work the unit-code system: whether to link one or not, (see Overlinking), and whether to link the numerator or denominator of a unit ratio separately.
{{val|number|ul=unit code}}
→ number symbol, such as 9,8 km2{{val|number|u=unit code}}
→ number symbol, such as 9,8 km2{{val|number|u=unit code|upl=unit code}}
→ number symbol/symbol, such as 9,8 gal/min{{val|number|ul=unit code|up=unit code}}
→ number symbol/symbol, such as 9,8 pc/letoTo bypass the unit code system, if |u=
does not recognize your unit code, it will accept any wikitext and render it as usual.
{{val|5,4|u=[[kg]]⋅[[meter|m]]/s<sup>2</sup>}}
→ 5,4 kg⋅m/s2{{val|7,6|u=[[metre per second squared|m/s<sup>2</sup>]]}}
→ 7,6 m/s2See Module:Val/units for how to add units to the unit code system.
Sometimes a number and unit code is not enough. A prefix or suffix are also available, |p=
and |s=
.
{{val|7600|u=C⋅Ga|p=>|s=<}}
→ >7600 C⋅Ga<{{val|7600|u=C|p=<span style="color:green"><sup>|s=</span></sup>}}
→ 7600 CSee {{val/testniprimeri}} to learn the val parameters by an example. It is comprehensive, and there are over 100 examples.
Val takes three unnamed parameters. The first is always the numeric value. When the second and third are numbers they become the various uncertainty notations, but the second unnamed parameter can also serve to grammatically join the first and third numbers.
Val clears surrounding spaces in its unnamed parameters.
1st or |1= |
A number in decimal comma notation or in e notation. The main basis of the Val expression.
|
|fmt=
|
By default, numbers are formatted with gaps separating groups of three digits in both integer and fractional part. However, by default, four-digit integers are not formatted; use |
|end= |
Put something at the end of the main number (before anything else that might follow).
|
2nd or |2= |
Uncertainty in either format.
|
3rd or |3=
|
Asymmetric uncertainty.
|
|errend= or |+errend= and |-errend= |
Appends something after an uncertainty.
|
|u= or |ul= |
The unit code. Val adds a space and the unit.
|
|up= or |upl= |
A unit code, but instead of a space Val adds a slash and the unit, a "per" unit (the denominator), to form a ratio.
|
|p= |
Prefix the entire Val expression. Non-spaced, but accepts markup.
|
|s= |
Suffix the entire Val expression. Non-spaced, but accepts markup.
|
|e=
|
Exponent. Val alternatively accepts e notation in the first parameter; these are mutually exclusive (see "1st" argument above).
|
|long scale= |
Usually a unit is the short ton and billion means 1×109. But there are long versions of these units and others. Use |long scale=on to assign your unit to the long scale instead. The unit code's link will change and it will sort differently in tables. "See Long and short scales".
|
|nocategory= |
If set to any value, errors in the use of this template will not cause the page to be added to the Strani z nepravilno uporabo predlog za oblikovanje category. This is useful for documentation and test pages that do not need to be fixed. |
There is strict checking on the validity of arguments; any incorrect use will result in an error, which is displayed using {{FormattingError}}. Pages that contain incorrect use of this template will show up on Kategorija:Strani z nepravilno uporabo predlog za oblikovanje.
Val checks for unsupported parameters and gives a relatively subtle warning if found. See tracking category to track any of these improper usages on existing on the wiki. Hold the mouse over "warning" to see details. Here is what warnings look like:
{{val|1,23|exp=6|u=m/s}}
→ 1,23 m/swarning{{val|1,23|us=kbit/s}}
→ 1,23warning{{val|1,23|,05|,04|,03|u=m/s}}
→ 1,23+,05{{Val}} produces formatting compliant with Wikipedia's Manual of Style.
The MOS recommends that numbers either be delimited using thin spaces either side of the decimal, or dots to the left and no delimiters to the right. Articles should be consistent with respect to the style of delimiting. The template defaults to the former style, this can be adjusted using |fmt=
(see above).
The sort key for each sortable unit is visible at Template:Val/list.
Here is a live example showing the minimal markup for a sortable table:
{| class="sortable" ! Val sort test |- | {{val|3|ul= Mm }} |- | {{val|5e6|u= m }} |- | {{val|1|u= km }} |- | {{val|2e3|u= m }} |- | {{val|4|u= m }} |} |
|
A sort value relates to a Val expression as follows.
{{val|1234567,1234567}}
→ 1234567,1234567
.{{val| 1234567,1234567 }}.
→ .1234567,1234567.
{{val|,1234567|fmt=dots}}
→ ,1234567
{{val|+1234567|fmt=dots}}
→ +1.234.567
{{val|-1234567}}
→ −1234567
{{val|1,234|0,005}}
→ 1,234±0,005
{{val|1,234|+0,005|-0,006}}
→ 1,234+0,005
−0,006
{{val|1,234|(5)}}
→ 1,234(5)
{{val|1,234|u=m}}
→ 1,234 m
{{val|1,234|u=m2}}
→ 1,234 m2
{{val|1,234|ul=m}}
→ 1,234 m
{{val|123,4|ul=USgal}}
→ 123,4 US gal
{{val|12,34|ul=mpgimp}}
→ 12,34 mpg-imp
{{val|12,34|u=deg}}
→ 12,34°
{{val|1,234|0,005|u='}}
→ 1,234′±0,005′
{{val|1,234|+0,005|-0,006|u="}}
→ 1,234″+0,005″
−0,006″
{{val|1,234|u=%}}
→ 1,234%
{{val|1,234|end= [[m/s]]}}
→ 1,234 m/s
{{val|12,34|u=degC}}
→ 12,34 °C
{{val|12,34|u=K}}
→ 12,34 K
{{val|1,234e5|ul=m}}
→ 1,234×105 m
{{val|1,234|e=5|ul=m}}
→ 1,234×105 m
{{val|1,234e7|0,056}}
→ (1,234±0,056)×107
{{val|1,234|0,056|e=7}}
→ (1,234±0,056)×107
{{val|1,23456e-9|+0,00007|-0,00008|ul=m/s}}
→ 1,23456+0,00007
−0,00008×10−9 m/s
{{val|1,23456|+0,00007|-0,00008|e=-9|ul=m/s}}
→ 1,23456+0,00007
−0,00008×10−9 m/s
{{val|1,234e7|0,056|ul=psi}}
→ (1,234±0,056)×107 psi
{{val|1,234|0,056|e=7|ul=psi}}
→ (1,234±0,056)×107 psi
{{val|1,234e-2|(5)}}
→ 1,234(5)×10−2
{{val|1,234|(5)|e=-2}}
→ 1,234(5)×10−2
{{val|12,34|p=Δ }}
→ Δ 12,34
{{val|12,34|u=%|p=≅}}
→ ≅12,34%
{{val|12,34|0,25|s=%}}
→ 12,34±0,25%
{{val|1,234|e=7|ul=W|up=m2}}
→ 1,234×107 W/m2
{{val|1,2|end={{overline|34}}|e=7|ul=W|up=m2}}
→ 1,234×107 W/m2
See the testcases at {{val/testniprimeri}}.
Val is now a module. Modules have excellent performance compared to the normal template that uses parser functions.
Performance data is reported by MediaWiki software in the HTML page source of every page, and a very similar report is available on any preview page, below the edit box, titles "Parser profile data".
For uses in any page, even long list articles, Module:Val will have very little impact on page-load times.
|ul=
to |u=
and from |upl=
to |up=
.