Template:Val/sandbox
这是Template:Val(差异)的沙盒。 参见本模板的测试样例。 |
本模板不应在引文模板(如引文格式1和引文格式2)中使用,因为本模板所含的标记会破坏引文模板生成的 COinS 元数据,更多信息请见“Wikipedia:COinS”。 |
此模板使用Lua语言: |
用法
便于使用科学计数法(包括不确定性)显示数值。
参数 | 描述 | 类型 | 状态 | |
---|---|---|---|---|
数值 | 1 | 无描述 | 未知 | 可选 |
不确定性(上界) | 2 | 无描述 | 未知 | 可选 |
不确定性下界 | 3 | 无描述 | 未知 | 可选 |
不加错误提示分类 | nocategory | 无描述 | 未知 | 可选 |
指数 | e | 无描述 | 未知 | 可选 |
单位 | u ul | 无描述 | 未知 | 可选 |
每 | up upl | 无描述 | 未知 | 可选 |
值前缀 | p | 无描述 | 未知 | 可选 |
主后缀 | end | 无描述 | 未知 | 可选 |
不确定性上界后缀 | +errend | 无描述 | 未知 | 可选 |
不确定性下界后缀 | -errend | 无描述 | 未知 | 可选 |
不确定性后缀 | errend | 无描述 | 未知 | 可选 |
值后缀 | s | 无描述 | 未知 | 可选 |
Purpose
This template is used to easily present values in scientific notation, including uncertainty and/or units, in accordance with the wikipedia manual of style. It wraps the entire result in a {{nowrap}} block, so that it never gets broken into separate pieces at the end of a line. (See WP:NBSP for more information on the usage of non-breaking spaces.)
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 ±56. 1234{{val|number|upper uncertainty|lower uncertainty}}
- for displaying values with uncertainty like so +56
−78. 1234{{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 " × 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).
|
p | A prefix for the value (such as ∆, ⌀, etc.; optional). |
s | A suffix for the value (such as %, optional).
|
end | Appends something after the main value. For example, {{val|123.24|end=...}} gives 123.24... |
errend | Appends something after the uncertainty. For example, {{val|123.23|end=...|2.34|errend=...}} gives ±2.34... 123.23... |
+errend & -errend | Appends something after the positive/negative uncertainties. For example, {{val|123.23|end=...|+2.34|+errend=...|-1.23|-errend=...}} gives +2.34... −1.23... 123.23... |
nocategory | If set to any value, errors in the use of this template will not cause the page to be added to the Pages with incorrect formatting templates use category. This is useful for documentation and test pages that do not need to be fixed. |
See {{val/test}} for a list of examples of the correct output of {{val}} and the errors it may return when incorrectly used.
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.
Format convention
As mentioned before, {{val}} should produce formatting compliant with the wikipedia manual of style. It currently produces 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., 100045 and 0.12345 and 5.12345). 125.123
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}}
→ 234567890 1 {{val|1.23456789}}
→ 56789 1.234 {{val|21563.252564425}}
→ 563.252564425 21[1] Uncertainty/significance {{val|1.234|0.005}}
→ ±0.005 1.234 {{val|1.234|+0.005|-0.006}}
→ +0.005
−0.006 1.234{{val|1.234|(5)}}
→ 1.234(5) Exponents/units {{val|1.234|e=5|u=m}}
→ ×105 米 1.234 {{val|1.234|e=5|u=m2}}
→ ×105 m2 1.234 {{val|1.234|e=5|ul=m}}
→ ×105 米 1.234 {{val|1.234|0.056|e=7}}
→ ±0.056)×107 (1.234 {{val|1.23456|+0.00007|-0.00008|e=-9|ul=m/s}}
→ 56+0.00007
−0.00008×10−9 m/s 1.234{{val|1.234|0.056|e=7|ul=psi}}
→ ±0.056)×107 psi (1.234 {{val|123.4|ul=USgal}}
→ US gal 123.4 {{val|12.34|ul=mpgimp}}
→ mi/imp gal 12.34 Prefix/suffix {{val|p=Δ |12.34|s=%}}
→ Δ 12.34%
參見
- {{Valid|有效}}:數字有效性檢查(對於參數1、2、3,e值和不確定性,以10為底的指數)
- {{FormattingError}} : 格式錯誤:用於報告不一致的參數
- {{Su}}:用於格式化指數,或者一個或多個二值不確定度的格式(等寬:當前無法打印為PDF)