Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Compact and Scientific Notation Syntax #5

Closed
sffc opened this issue May 15, 2018 · 2 comments
Closed

Compact and Scientific Notation Syntax #5

sffc opened this issue May 15, 2018 · 2 comments

Comments

@sffc
Copy link
Collaborator

sffc commented May 15, 2018

This thread is about the syntax for compact notation and scientific notation.

Compact notation uses localized suffixes like "K" and "M" to represent the magnitude. Scientific notation uses an exponential separator, like "E", followed by a power of ten.

Older versions of ICU exposed each of these as separate "styles" of DecimalFormat. However, newer ICU lets you combine scientific or compact notation with all other number formatting features.

I suggest the following basic syntax:

{ notation: "scientific" }  // 1.2E3
{ notation: "compact-short" }  // 1.2K
{ notation: "compact-long" }  // 1.2 thousand

In addition, we might want to expose additional options for scientific notation. ICU supports three options:

  • Engineering notation (exponent is always a multiple of 3)
  • Minimum exponent digits: "1.2E03"
  • Exponent sign display: "1.2E+3"

If we want to bring these additional options into Ecma 402, we could do something like,

{ notation: "engineering" }
{ notation: "scientific", minimumExponentDigits: 3 }
{ notation: "scientific", exponentSign: "always" }

References:

Comments?

@littledan
Copy link
Member

LGTM

@littledan
Copy link
Member

We discussed this question in the May 2018 Intl meeting. The conclusion was to split this into two options:

  • notation: "engineering"/"scientific"/"compact"
  • display: "short"/"narrow"/"long"
  • Leave further options like minimumExponentDigits and exponentSign for future extensions

@sffc sffc closed this as completed Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants