Purpose सम्पादन

This template is used to easily present values in scientific notation, including uncertainty and/or units. It wraps the entire result in a {{nowrap}} block, so that it never gets broken into separate pieces at the end of a line.

Arguments सम्पादन

There are four ways this template can be used:

  • {{val|number}} - for displaying values without uncertainty/significance.
  • {{val|number|uncertainty}} - for displaying values with uncertainty like so १,२३४±५६.
  • {{val|number|upper uncertainty|lower uncertainty}} - for displaying values with uncertainty like so १,२३४+५६−७८.
  • {{val|number|(significance)}} - for displaying values with significance like so १,२३४(56).

They all take roughly the same arguments:

1 The value (must be a valid number)
2 The (upper limit of) uncertainty (must be a valid number) or significance (must be a valid number in parenthesis)
3 The lower limit of uncertainty (must be a valid negative number)
e The exponent for the power of 10 (optional). This will show up in the result as " × 10e".
u / ul The units for the number (optional, with/without a link to the page about the unit respectively).
up / upl The units per for the units (optional, requires u to be specified, with/without a link to the page about the unit respectively).
Units (specified by u, ul, up and upl) are replaced by a more aesthetically pleasing HTML representation and get a link (ul and upl only, if they are in the list found in {{val/units}} or if they are supported by {{convert}}). You can specify units using just u; a good example is "ul=m/s", which gets translated to "m·s-1", or you can use u and up, as in "u/up"; a good examples if "ul=m|up=s", which gets translated to "m/s".
p A prefix for the value (such as ∆, ⌀, etc.; optional).
s A suffix for the value (such as %, optional).
Prefixes (specified by p) and suffixes (specified by s) are put in front of or behind the value as is: this includes spaces. They are inside the nowrap block and will always be on the same line as the value. The parameters that previously provided this functionality (h for header and f for footer) are deprecated and will be ignored.
end Appends something after the main value. For example, {{val|123.24|end=...}} gives १२३.24...
errend Appends something after the uncertainty. For example, {{val|123.23|end=...|2.34|errend=...}} gives १२३.23...±२.34...
+errend & -errend Appends something after the positive/negative uncertainties. For example, {{val|123.23|end=...|+2.34|+errend=...|-1.23|-errend=...}} gives १२३.23...+२.34...−१.23...

Errors सम्पादन

There is strict checking on the validity of arguments; any incorrect use will result in an error, which is displayed using {{Formatting error}}.

Format convention सम्पादन

{{val}} should produce formatting compliant with the U.S. Government Printing Office Style Manual, in rules 12.9e and 12.14, which requires that the decimal separator be a full stop; i.e. “decimal point” (.), requires comma-delimiting to the left of the decimal point for numbers with four or more digits to the left (values of १,००० or more), and also requires space-delimiting to the right of the decimal point for numbers containing five or more digits to the right (e.g., ०.12345 and ५.12345 and १२५.12345).

Note that if {{val}} is used on numbers simultaneously comprising four or more digits to the left of the decimal point and five or more digits to the right, the resultant expression will delimited with commas left and spaces (actually non-selectable, non-breaking, narrow gaps) right (see below).

Examples सम्पादन

{{val|1234567890}}  →  १,२३,४५,६७,८९०
{{val|1.23456789}}  →  १.23456789
{{val|21563.252564425}}  →  २१,५६३.252564425
Uncertainty/significance
{{val|1.234|0.005}}  →  १.234±०.005
{{val|1.234|+0.005|-0.006}}  →  १.234+०.005−०.006
{{val|1.234|(5)}}  →  १.234(5)
Exponents/units
{{val|1.234|e=5|u=m}}  →  १.234×10 m
{{val|1.234|e=5|u=m2}}  →  १.234×10 m2
{{val|1.234|e=5|ul=m}}  →  १.234×10 m
{{val|1.234|0.056|e=7}}  →  १.234±०.056×10
{{val|1.23456|+0.00007|-0.00008|e=-9|ul=m/s}}  →  १.23456+०.00007−०.00008×10−९ m/s
{{val|1.234|0.056|e=7|ul=psi}}  →  १.234±०.056×10 psi
{{val|123.4|ul=USgal}}  →  १२३.4 US gal
Prefix/suffix
{{val|p=Δ |12.34|s=%}}  →  Δ १२.34%

Performance impact सम्पादन

For most uses, in the text of pages, Template:Val will not restrict performance, but when used inside the wikitext markup of large templates, there are some restrictions. When displaying integer amounts, Template:Val has an internal expansion depth of 15 levels, but for numbers with decimal portions, it uses 22 levels, or more.

See also सम्पादन

  • {{Valid}} : number validity checking (for parameters 1, 2, 3, e : value, and uncertainties, base-10 exponent)
  • {{Formatting error}} : for reporting inconsistent parameters
  • {{Su}} : for formatting exponents, or two-values incertainty one below the other (monospaced : currently not printable to PDF)
  • {{±}} : for positive <sup> and negative <sub>
  • {{Val/delimitnum}} : for formatting a decimal number with delimiters between groups of digits
  • {{Val/units}} : for formatting unit names (contents of parameters u or up)
  • {{Val/unitswithlink}} : for formatting unit names with links (contents of parameters ul or upl)