New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Compact Decimal Format to abbreviate large numbers #37

Open
caridy opened this Issue Sep 19, 2015 · 9 comments

Comments

Projects
None yet
7 participants
@caridy
Collaborator

caridy commented Sep 19, 2015

CLDR contains the details to abbreviate large numbers, e.g.:

        "decimalFormats-numberSystem-latn": {
          "standard": "#,##0.###",
          "long": {
            "decimalFormat": {
              "1000-count-one": "0 thousand",
              "1000-count-other": "0 thousand",
              "10000-count-one": "00 thousand",
              "10000-count-other": "00 thousand",
              "100000-count-one": "000 thousand",
              "100000-count-other": "000 thousand",
              "1000000-count-one": "0 million",
              "1000000-count-other": "0 million",
              "10000000-count-one": "00 million",
              "10000000-count-other": "00 million",
              "100000000-count-one": "000 million",
              "100000000-count-other": "000 million",
              "1000000000-count-one": "0 billion",
              "1000000000-count-other": "0 billion",
              "10000000000-count-one": "00 billion",
              "10000000000-count-other": "00 billion",
              "100000000000-count-one": "000 billion",
              "100000000000-count-other": "000 billion",
              "1000000000000-count-one": "0 trillion",
              "1000000000000-count-other": "0 trillion",
              "10000000000000-count-one": "00 trillion",
              "10000000000000-count-other": "00 trillion",
              "100000000000000-count-one": "000 trillion",
              "100000000000000-count-other": "000 trillion"
            }
          },
          "short": {
            "decimalFormat": {
              "1000-count-one": "0K",
              "1000-count-other": "0K",
              "10000-count-one": "00K",
              "10000-count-other": "00K",
              "100000-count-one": "000K",
              "100000-count-other": "000K",
              "1000000-count-one": "0M",
              "1000000-count-other": "0M",
              "10000000-count-one": "00M",
              "10000000-count-other": "00M",
              "100000000-count-one": "000M",
              "100000000-count-other": "000M",
              "1000000000-count-one": "0B",
              "1000000000-count-other": "0B",
              "10000000000-count-one": "00B",
              "10000000000-count-other": "00B",
              "100000000000-count-one": "000B",
              "100000000000-count-other": "000B",
              "1000000000000-count-one": "0T",
              "1000000000000-count-other": "0T",
              "10000000000000-count-one": "00T",
              "10000000000000-count-other": "00T",
              "100000000000000-count-one": "000T",
              "100000000000000-count-other": "000T"
            }
          }
        },

@rxaviers proposed this feature a while ago IIRC, but I could find the thread, so I'm posting it here to formalize the proposal.

Proposal

This proposal goes hand-to-hand with the pluralization (#34) since it will have to compute what's the pluralization token to choose the right format (In the CLDR data you will see that for english we have a lot of *-count-one and *-count-other).

The initial proposal could be to add one more configuration to specify either:

a) best-fit for the abbreviation, which means we choose the biggest matching decimal from the segments
b) the decimal reference to force to use a particular formatting option (e.g.: 10000, which could produce 1234K);

new Intl.NumberFormat('en', { compact: 'best-fit' }).format(1234000); // 1.2M
new Intl.NumberFormat('en', { compact: '4-digits' }).format(1234000); // 1234K

Open questions

  • how to match this with currency values so we can produce something like $12M.
  • the name of the configuration option when creating a new Intl.NumberFormat()
  • 1M vs 1.2M
  • 1M vs 1 Million (this will probably require another configuration to specify long vs short.
  • rounding and custom rounding settings? (related to rxaviers/ecma402-number-format-round-option#1 (comment))

/cc @jfparadis @zbraniecki

@caridy caridy added the enhancement label Sep 19, 2015

@caridy

This comment has been minimized.

Collaborator

caridy commented Sep 19, 2015

More details about CLDR Compact Decimal Format here: http://www.unicode.org/cldr/charts/27/summary/pl.html#4032

@zbraniecki

This comment has been minimized.

Collaborator

zbraniecki commented Sep 19, 2015

Probably same algorithm will be useful as for issue #32. ("1.2 M" vs. "2.5 KB")

@srl295

This comment has been minimized.

Member

srl295 commented Sep 22, 2015

@rxaviers

This comment has been minimized.

Member

rxaviers commented Sep 22, 2015

@steveluscher

This comment has been minimized.

steveluscher commented Sep 23, 2015

Can you link to this rounding discussion in your list of open questions, @caridy?

@caridy

This comment has been minimized.

Collaborator

caridy commented Sep 23, 2015

@steveluscher added.

@charoseth

This comment has been minimized.

charoseth commented Dec 23, 2017

Any progress/plan for this proposal?
This is quite useful for some statistical data shown in analysis softwares for localization.

@caridy

This comment has been minimized.

Collaborator

caridy commented Dec 23, 2017

It is an active proposal, but we need a champion!

@sffc

This comment has been minimized.

Contributor

sffc commented Feb 12, 2018

See my follow-up in #215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment