Template:Val/delimitnum/fraction/doc

From TechInfoDepot
Jump to navigationJump to search
{{Val/delimitnum/fraction |0.123456 |6}}   → 123456

The Template:Val/delimitnum/fraction is used by template {{Val}}. It formats a positive number lower than 1, using a given number of decimal digits after a decimal dot. It does not show the dot ("."), only the digits, in groups of 3 or 4, separated by thin spaces (small gaps).

Parameters

Parameter 1 is the required positive value to display lower than 1 (i.e. the fractional part of a positive real, with no spaces). Note that its value is not restricted in this template, as it is assumed to be valid (see {{Val/delimitnum}} for how it is computed). The amount in {1} could be an entire number (3400.65), but only the decimal portion will be displayed ("65").

Parameter 2 is the number of decimals to display (the count of digits after the decimal dot).

Examples

  • {{Val/delimitnum/fraction|0.12345|5}} → 12345
  • {{Val/delimitnum/fraction|0.12345|4}} → 1234
  • {{Val/delimitnum/fraction|0.54321|8}} → 54321000
  • {{Val/delimitnum/fraction|0.98765432101234|14}} → 98765432101234
  • {{Val/delimitnum/fraction|560.123|3}} → 123
  • {{Val/delimitnum/fraction|99000800.7|1}} → 7

Messages

The following messages might appear:

  • Too many digits. - when parameter 2 > 14.
  • Expression error: Unexpected number. - when invalid spaces in number "0.123 456".
  • Expression error: Unrecognised punctuation...{. - if exceeded expansion depth limit.

Performance impact

Template:Val/delimitnum/fraction limits the count of decimal digits to 14, based on the limit of computer math for the server computers. For higher counts, it shows: Too many digits.. In most uses, within the text of articles, using the template will not restrict performance, but when used inside the wikitext markup of very large templates, there are some restrictions. To display just 1 decimal digit, Val/delimitnum/fraction has an internal expansion depth of 4 levels, adding 1 level for each digit of the decimal portion.

For a 7-digit decimal (such as: 0.1234567), it uses a depth of 10 levels (4+6). At the maximum, for a 14-digit decimal (such as: 0.98765432101234), it uses a depth of 17 levels (4+13). In the rare event of exceeding the expansion depth limit, an expression error will be displayed, such as: Expression error: Unrecognised punctuation character "{". In general usage, most numbers rarely have more than 5 decimal digits (expansion depth of 8 levels).

See also

  • {{Val/delimitnum}} to format an entire number, including decimal portion.
  • {{gaps}} to insert gaps between multiple numbers or letters.