Template:Val/doc

Purpose
This template is used to easily present values in scientific notation, including uncertainty and/or units, as prescribed by Wikipedia's 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: They all take roughly the same arguments
 * - for displaying values without uncertainty/significance.
 * - for displaying values with uncertainty like so $1,234$.
 * - for displaying values with uncertainty like so $1,234$.
 * - for displaying values with significance like so $1,234$.

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 using formatting templates incorrectly.

Format convention
As mentioned before, val should produce formatting compliant with Wikipedia's 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 $e$ 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., $123.24$ and $123.24$ and $123.23$).

Note that if 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



 * colspan=3|Uncertainty/significance
 * colspan=3|Exponents/units
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Uncertainty/significance
 * colspan=3|Exponents/units
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Exponents/units
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Exponents/units
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Prefix/suffix
 * colspan=3|Numerator/Denominator
 * }
 * colspan=3|Numerator/Denominator
 * }
 * }
 * }
 * }

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.

How to add units
The unit you will add is required to have a link version and a non-link version for stylistic reasons (including the ability of editors to avoid overlinking). The link version will be added to Val/unitswithlink to process the  and   parameters. The non-link version might need to be added to Val/units to process the  and   parameter; it depends on whether or not the unit needs markup, or if the characters users will give to the   or   parameter are different than what is displayed, or if "technical reasons" are discovered. (See below.)

FAQ and comments

 * Q: Why should I use val?
 * A1: Val formats numbers:
 * inserts commas into large numbers and spaces between decimal digits
 * handles uncertainties in measurements and significant digits, providing a ± character, etc.
 * handles exponents of 10 and scientific notation
 * replaces "-" (hyphen) with a "&minus;" (minus sign)
 * A2: It preserves spacing:
 * It makes sure the value does not wrap at the end of a line, so that it can always be read as a single value on one line in the text.
 * It spaces the various parts of the value where they should be
 * A3: It automates the markup for, and a link to a displayed unit.
 * A4: Val helps make Wikipedia more consistent. It adheres to the Wikipedia Manual of Style for numbers. Updates to the Wikipedia Manual of Style for numbers can be applied to this template, and result in automatic modification on values that use val. All this makes sure all values on all pages have the same look and feel because they will all use the same spacing, font size, positioning, etc, and makes updating and checking by the bots easier because they can recognize a value for what it is.


 * Q: Why not use ?
 * A: For the same reasons HTML might be preferred over :
 * Because the font in math tags differs both in face and size from the prose, which can disturb the layout of a page when used inline with the prose.
 * You cannot cut and paste a bitmap image rendered by the Latex.
 * Images are slower to load and use more bandwidth, which is especially bad for the mobile version of Wikipedia.
 * does not automatically adhere to the Wikipedia Manual of Style for numbers.


 * Q: Are there any known issues with val?
 * A1: Because numbers can only be stored with a limited precision by Wikipedia servers, val cannot handle very large numbers, such as 123456789123456789. This is reported using a FormattingError, so it should be easy to spot. Since there is very limited use for such large numbers, there is no fix planned for this.
 * A2: This template has been in full use on many pages for quite some time without major problems or breaking changes. Technically, there is no good reason not to try val.

Related pages

 * 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)
 * : for positive    and negative    
 * 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)