Extension talk:FormatNum

Jump to navigation Jump to search

About this board

Verdy p (talkcontribs)

The implementation currently uses   (U+2009 THIN SPACE) for the abbreviation "t" supported as a group separator (incorrectly named thousand separator in the doc, because most South-Asian languages group digits differently).

But that thin space is incorrect because it is breakable.

The correct code should be using &x202F; (U+202F NARROW NON-BREAKING SPACE). It has a known named character entity &nnbsp; that mat be used instead of the numeric character entity, but unfortunately still not recognized by all HTML parsers. But nothing prohibit Mediawiki recognizing that named entity, because many users are searching the correct code to use (which is definitely not   like you did!)

Note that the need of these thin spaces is especially highly recommended for the standard French typographic fine, which must necessarily be unbreakable, and also needed by ISO instead of the ambiguous comma of English (and highly prefered to   (U+00A0 NON-BREAKING SPACE, but NBSP is still better as a fallback than THINSP, which must never be used in any normal number... except for very long numbers where a break is sometimes needed, generally only between groups of about 60 digits, i.e. for a width of 30em for just the digits, or about 33 to 35em when including their group separators every 3 or 5 digits !)

Note that "formatnum" still does not support very long numbers, which need a secondary (breakable) group separator (every N groups, an alternate separator like ,  or   or just   may be used instead of the normal group separator, the default being every 20 primary groups of 3 digits) so they can break more cleanly. It is only for that THINSP may be used instead of NNBSP, for the large group separator.

Verdy p (talkcontribs)

Also you should support a language code parameter to select automatically the correct formatting of decimal numbers, notably

  • the correct set of decimal digits (See the Unicode general category "Nd"),
  • the correct group sizes (not 3 in all language, South Asian languages have a lowest group of 4 digits, then group every 2 or 3 digits),
  • the correct group (typically comma or nnbsp) and decimal (typically dot or comma) separators,
  • correct signs and sign position or the notation of negative numbers...

See Unicode CLDR data about these formats per locale, or their implementation in ICU.

Reply to "thin separator"

How to make FormatNum work correctly

2
212.80.62.177 (talkcontribs)

Englich wiki: works fine

  • {{#explode:100,000| |0}} → 100,000
  • {{#explode:100.000| |0}} → 100.000
  • {{#explode:100,000| |0}} → 100,000

Russian wiki: Not working properly

  • {{#explode:100,000| |0}} → 100 000
  • {{#explode:100.000| |0}} → 100,000
  • {{#explode:100,000| |0}} → 100 000

How to fix it? (Oleksiy) 212.80.62.177 13:23, 9 October 2018 (UTC)

212.80.62.177 (talkcontribs)

oops wrong code

  • 100,000 → 100 000 no comma
Reply to "How to make FormatNum work correctly"

decimal comma system into en. decimal point

9
Pinky sl (talkcontribs)

Can you tell me the result of this usage before we install this extension on slovenian wikipedia:

{{#formatnum: 2300,123|2|,|.}} gives result: 2,300.12 or 2300.12
{{#formatnum: 2300|2|,|.}} gives result: 2,300 or 2300
{{#formatnum: 1.234.567,89|2|,|.}} gives result: ?, it should be 1234567.89 or 1,234,567.89

The problem was that we want that parameters in our infoboxes contains input decimal comma system and we must prepare the number for further calculations in engish decimal point system.

DaSch (talkcontribs)
Pinky sl (talkcontribs)
DaSch (talkcontribs)

the problem is, that when using . as seperator for thousands this is recogniced as decimal seperator because of this I added another parameter so that you can specify the sepeator for thousands so that it can be removed

DaSch (talkcontribs)

I added some lines so that the seperator will be guessed. this will only work if it's clear which one is the thousand sepeator and which the decimal seperator

Pinky sl (talkcontribs)

Its better, but still:

{{#formatnum: 2.300|2|.|}} → 2.30 it should be 2300.12
{{#formatnum: 10.000|2|.|}} → 10.00 it should be 10000.00
DaSch (talkcontribs)

how can the parser know, that the point is a thousend seperator and not a decimal seperator? when adding otsep=. you will get the behaviour you want. Then the parser know that the . is a thousand seperator.

Pinky sl (talkcontribs)

Thanks. It works fine for me (or I should say slovenian wikipedians) and I will recomend this Extension for installation. This will have a large improvement in our templates (calculating population density, all sorts of conversions). We still have to do some voting about this, but I dont see any problems. Are all changes you made in the latest version - 0.5.1 (2012-08-27)?

And I am sorry about my dummy questions, I am new in Media wiki (till now I was just Media wiki user).

DaSch (talkcontribs)

There are no new changes. The latest version 0.5.1 contains all you can test on the Web Community Wiki.

No problem, I liked to help.

Reply to "decimal comma system into en. decimal point"
There are no older topics