ଛାଞ୍ଚ:Gapnum/dec/doc

ଉଇକିପିଡ଼ିଆ‌ରୁ

The formatter Template:Gapnum/dec formats only the fractional decimal portion of any number, by inserting small gaps between decimal digits, displayed in groups of 3 or 4 decimal digits. The gap size can be set (default: 0.25em). To format an entire number, use {{gapnum}} instead.

Usage[ସମ୍ପାଦନା]

{{Gapnum/dec |0.123456 |6}}   → 123456
{{Gapnum/dec |0.123000777 |9|gap=11px}}   → 123000777

This template formats the decimal portion of a number, showing a specified number of decimal digits. It does not show the dot ("."), only the digits, in groups of 3 or 4, separated by narrow spaces (small gaps), as the left-margin space of digit groups.

Parameters[ସମ୍ପାଦନା]

Parameter 1 is a positive number (with no embedded spaces) for displaying the decimal part. Note that its value is not restricted in this template, as it is assumed to be valid. The amount in {1} could be an entire number (such as 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 point), and can be less, or more than the actual number to show trailing zeroes.

Parameter gap=3px sets the gap between digit groups (default: gap=0.25em).

Examples[ସମ୍ପାଦନା]

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

Messages[ସମ୍ପାଦନା]

The following messages might appear:

  • Parameter 2 more than 14 digits. - limit is 14 digits after the decimal.
  • Expression error: Unexpected number. - when invalid spaces in number "0.123 456".
  • Expression error: Unrecognised punctuation...{. - if exceeded expansion depth limit.

Performance impact[ସମ୍ପାଦନା]

Template:gapnum/dec limits the count of decimal digits to 14, based on the limit of computer math for the server computers. 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 minor restrictions. To display just 1 decimal digit, Val/delimitnum/fraction has an internal expansion depth of 3 levels, regardless of the number of digits in the decimal portion.

At the maximum, for a 14-digit decimal (such as: 0.98765432101234), it also uses a depth of 3 levels. 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 templates rarely use more than 30 levels (leaving expansion depth of at least 10 levels to fit the 3 needed).

See also[ସମ୍ପାଦନା]

  • {{gapnum}} - formats an entire number with gaps between digits
  • {{Val/delimitnum}} - formats entire number with commas & decimal gaps
  • {{gaps}} - to insert gaps between multiple numbers or letters