الگو:Val/توضیحات: تفاوت میان نسخهها
dezfulwiki>Yamaha5 بدون خلاصۀ ویرایش |
جز (۱ نسخه واردشده) |
(بدون تفاوت)
|
نسخهٔ کنونی تا ۱۹ اکتبر ۲۰۲۱، ساعت ۱۲:۵۶
این زیرصفحهٔ مستندات الگو:Val است. این شامل اطلاعات استفاده، الگوها و سایر اطلاعات است که در اصل الگو صفحه قرار نمیگیرد. |
Purpose
This template is used to easily present values in scientific notation, including uncertainty and/or units, as prescribed by Wikipedia's . 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 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 ±۵۶ ۱۲۳۴.{{val|number|upper uncertainty|lower uncertainty}}
- for displaying values with uncertainty like so +۵۶
−۷۸ ۱۲۳۴.{{val|number|(significance)}}
- for displaying values with significance like so ۱۲۳۴(۵۶).
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 ۱۲۳٫۲۴٫٫٫ |
errend | Appends something after the uncertainty. For example, {{val|123.23|end=...|2.34|errend=...}} gives ±۲٫۳۴٫٫٫ ۱۲۳٫۲۳٫٫٫ |
+errend & -errend | Appends something after the positive/negative uncertainties. For example, {{val|123.23|end=...|+2.34|+errend=...|-1.23|-errend=...}} gives +۲٫۳۴٫٫٫ −۱٫۲۳٫٫٫ ۱۲۳٫۲۳٫٫٫ |
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 Wikipedia's . 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 نقطه (ادبی); 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., ۴۵ ۰٫۱۲۳ and ۴۵ ۵٫۱۲۳ and ۴۵ ۱۲۵٫۱۲۳).
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}}
→ ۵۶۷۸۹ ۱٫۲۳۴ {{val|21563.252564425}}
→ ۵۶۳٫۲۵۲۵۶۴۴۲۵ ۲۱ [۱] Uncertainty/significance {{val|1.234|0.005}}
→ ±۰٫۰۰۵ ۱٫۲۳۴ {{val|1.234|+0.005|-0.006}}
→ +۰٫۰۰۵
−۰٫۰۰۶ ۱٫۲۳۴{{val|1.234|(5)}}
→ ۱٫۲۳۴(۵) Exponents/units {{val|1.234|e=5|u=m}}
→ ×۱۰۵ m ۱٫۲۳۴ {{val|1.234|e=5|u=m2}}
→ ×۱۰۵ m۲ ۱٫۲۳۴ {{val|1.234|e=5|ul=m}}
→ ×۱۰۵ m ۱٫۲۳۴ {{val|1.234|0.056|e=7}}
→ ±۰٫۰۵۶)×۱۰۷ (۱٫۲۳۴ {{val|1.23456|+0.00007|-0.00008|e=-9|ul=m/s}}
→ ۵۶+۰٫۰۰۰۰۷
−۰٫۰۰۰۰۸×۱۰−۹ m/s ۱٫۲۳۴{{val|1.234|0.056|e=7|ul=psi}}
→ ±۰٫۰۵۶)×۱۰۷ psi (۱٫۲۳۴ {{val|123.4|ul=USgal}}
→ US gal ۱۲۳٫۴ {{val|12.34|ul=mpgimp}}
→ mpg&#۸۲۰۹;imp ۱۲٫۳۴ Prefix/suffix {{val|p=Δ |12.34|s=%}}
→ Δ ۱۲٫۳۴%
Performance impact
For most uses, in the text of articles, 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)
- {{FormattingError}} : for reporting inconsistent parameters
- {{Val/delimitnum}} : for formatting a decimal number with delimiters between groups of digits
- {{Su}} : for formatting exponents, or two-values incertainty one below the other (monospaced : currently not printable to PDF)
- {{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)