Template:Val/doc: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>SkyLined
m Updated examples to reflect new checks for too large numbers
meta>SkyLined
→‎Arguments: Moved into a table and reordered
Line 12: Line 12:
* <code><nowiki>{{val|''number''|(''significance'')}}</nowiki></code> - for displaying values with significance like so {{val|1234|(56)}}.
* <code><nowiki>{{val|''number''|(''significance'')}}</nowiki></code> - for displaying values with significance like so {{val|1234|(56)}}.
They all take roughly the same arguments
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)
| '''1''' || The value (must be a valid number)
:'''3''' The lower limit of uncertainty (must be a valid negative number)
|-
:'''e''' The exponent for the power of 10 (optional).
| '''2''' || The (upper limit of) uncertainty (must be a valid number) or significance (must be a valid number in parenthesis)
:'''u''' The units for the number (optional).
|-
:'''up''' The units per for the units (optional, requires '''u''' to be specified).
| '''3''' || The lower limit of uncertainty (must be a valid negative number)
:'''h''' A header for the value (such as ∆, Ø, etc.., optional).
|-
:'''f''' A footer for the value (such as %, optional).
| '''e''' || The exponent for the power of 10 (optional). This will show up in the result as as "&nbsp;×&nbsp;10{{su|p=e}}".
Values (arguments 1-3) are run through code copied from {{tl|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.'''
|-
 
| ||<DIV style="margin-left:2em;">Values (arguments '''1'''-'''3''' and '''e''') are run through code copied from {{tl|delimitnum}} for readability, except for argument '''2''' when it is surrounded by parenthesis. '''This currently causes an error for large numbers, numbers that require high precision and numbers that end in zeros after the decimal point. This last issues is being addressed, the other issues are a caused by a limitation in the wikipedia software for which there currently is no known fix.'''
Exponents (specified by '''e''') are exponents of 10 and will show up as "&nbsp;×&nbsp;10{{su|p=e}}".
|-
 
| '''u''' || The units for the number (optional).
Units (specified by '''u''' and '''up''') are replaced by a more esthetically pleasing HTML representation and get a link, if they are in the list found in {{tl|ScientificValue/units}} or if they are supported by {{tl|convert}}. You can specify units using just '''u'''; a good example is "u=m/s", which gets translated to "[[Meter per second|m·s<sup>-1</sup>]]", or you can use '''u''' and '''up''', as in "u/up"; a good examples if "u=m|up=s", which gets translated to "[[Meter|m]]/[[Second|s]]".
|-
 
| '''up''' || The units per for the units (optional, requires '''u''' to be specified).
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.
|-
| ||<DIV style="margin-left:2em;">Units (specified by '''u''' and '''up''') are replaced by a more esthetically pleasing HTML representation and get a link if they are in the list found in {{tl|val/units}} or if they are supported by {{tl|convert}}. You can specify units using just '''u'''; a good example is "u=m/s", which gets translated to "[[Meter per second|m·s<sup>-1</sup>]]", or you can use '''u''' and '''up''', as in "u/up"; a good examples if "u=m|up=s", which gets translated to "[[Meter|m]]/[[Second|s]]".</DIV>
|-
| '''h'''  || A header for the value (such as ∆, Ø, etc.., optional).
|-
| '''f'''  || A footer for the value (such as %, optional).
|-
| ||<DIV style="margin-left:2em;">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.</DIV>
|}


== Errors ==
== Errors ==

Revision as of 15:16, 17 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). This will show up in the result as as " × 10e
".
Values (arguments 1-3 and e) are run through code copied from {{delimitnum}} for readability, except for argument 2 when it is surrounded by parenthesis. This currently causes an error for large numbers, numbers that require high precision and numbers that end in zeros after the decimal point. This last issues is being addressed, the other issues are a caused by a limitation in the wikipedia software for which there currently is no known fix.
u The units for the number (optional).
up The units per for the units (optional, requires u to be specified).
Units (specified by u and up) are replaced by a more esthetically pleasing HTML representation and get a link 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 "u=m/s", which gets translated to "m·s-1", or you can use u and up, as in "u/up"; a good examples if "u=m|up=s", which gets translated to "m/s".
h A header for the value (such as ∆, Ø, etc.., optional).
f A footer for the value (such as %, optional).
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|1234567890}}  →  1234567890
{{val|1.23456789}}  →  1.23456789
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=Δ&nbsp;|12.34|f=%}}  →  12.34Error in {{val}}: Val parameter "f=%" is not supported