Template:Val/doc: Difference between revisions
meta>SkyLined Removed u=% documentation, added f argument documentation |
meta>SkyLined →Examples: Added header/footer example |
||
Line 59: | Line 59: | ||
|- | |- | ||
|<code><nowiki>{{val|12.34|u=mpgimp}}</nowiki></code>|| → ||{{val|12.34|u=mpgimp}} | |<code><nowiki>{{val|12.34|u=mpgimp}}</nowiki></code>|| → ||{{val|12.34|u=mpgimp}} | ||
|- | |||
|colspan=3|'''Header/footer''' | |||
|- | |||
|<code><nowiki>{{val|h=Δ&nbsp;|12.34|f=%}}</nowiki></code>|| → ||{{val|h=Δ |12.34|f=%}} | |||
|} | |} | ||
[[Category:Wikipedia formatting templates|ScientificValue]] | [[Category:Wikipedia formatting templates|ScientificValue]] |
Revision as of 14:04, 15 April 2008
Template:Template doc page viewed directly
Purpose
Set of templates that can be used to easily present values in scientific notation, including uncertainty. They have the same look and feel and wrap the entire result in a"nowrap" block, so it never gets broken in seperate 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 1234±56.{{val|''number''|''upper uncertainty''|''lower uncertainty''}}
- for displaying values with uncertainty like so 1234+56
−78.{{val|''number''|(''significance'')}}
- for displaying values with significance like so 1234(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).
- u The units for the number (optional).
- h A header for the value (such as ∆, Ø, etc.., optional).
- f A footer for the value (such as %, optional).
Values (arguments 1-3) are run through code copied from {{delimitnum}} for readability. This may mess them up if the last few digits are on the right hand side of the decimal dot and they are zero. This is a known issue.
Exponents (specified by e) are exponents of 10 and will show up as " × 10e
".
Units (specified by u) are replaced by a more esthetically pleasing HTML representation and get a link, if they are in the list found in {{ScientificValue/units}} or if they are supported by {{convert}}. A good example is "m/s", which gets translated to "m·s-1".
Headers (specified by h) and footers (specified by f) 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.
Errors
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 Category:Pages with incorrect formatting templates use.
Test
To see if this template is working correctly (for instance after you've made a change to the code), have a look at: {{Val/test}}. It contains a number of tests.
Examples
{{val|123456789.0123456789}}
→ 123456789.0123456789 Uncertainty/significance {{val|1.234|0.005}}
→ 1.234±0.005 {{val|1.234|+0.005|-0.001}}
→ 1.234+0.005
−0.001{{val|1.234|(5)}}
→ 1.234(5) Exponents/units {{val|1.234|e=10|u=m}}
→ 1.234×1010 m {{val|1.234|0.05|e=5}}
→ Template:Val± {{val|1.234567|+0.00005|-0.00004|e=-23|u=m/s}}
→ 1.234567+0.00005
−0.00004×10−23 m/s{{val|1.234567|0.04|e=3|u=psi}}
→ (1.234567±0.04)×103 psi {{val|123.4|u=USgal}}
→ 123.4 US gal {{val|12.34|u=mpgimp}}
→ 12.34 mpg‑imp Header/footer {{val|h=Δ |12.34|f=%}}
→ 12.34Error in {{val}}: Val parameter "f=%" is not supported