Skip to content
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

Normative: Split out BigInt formatting functions #318

Closed
wants to merge 2 commits into from

Commits on Jan 25, 2019

  1. Normative: Support BigInt in NumberFormat and toLocaleString

    This patch brings Intl.NumberFormat support to BigInt, and
    adds a BigInt.prototype.toLocaleString method based on it.
    
    The design here is to include overloading between BigInt and Number
    as arguments for the format and formatToParts methods based on
    ToNumeric. This means that, for example, string arguments are
    cast to Number, rather than BigInt. This design preserves
    compatibility and consistency with operators like unary -
    
    This definition permits options in the NumberFormat to force
    decimal places, e.g., 1n formatting as 1.00000 if the minimum
    fractional digits is 5. Alternative semantics would be to
    throw an exception in this case.
    
    For the algorithm text itself: the specification algorithms
    ToRawPrecision and ToRawFixed are now used for both Numbers
    and BigInts. Given the ECMAScript specification's use of implicit
    coercisions between Numbers and mathematical values, I believe
    that this is valid without any special changes; the phrasing
    may change in the future [1].
    
    ICU4C-based implementations of ECMAScript can use
    LocalizedNumberFormatter::formatDecimal [2] or
    unum_formatDecimal [3] to implement the algorithms in this patch.
    
    [1] tc39/ecma262#1135
    [2] http://icu-project.org/apiref/icu4c/classicu_1_1number_1_1LocalizedNumberFormatter.html#a29cd3d107b784496e19175ce0115f26f
    [3] http://icu-project.org/apiref/icu4c/unum_8h.html#a59870a322f012dc1b9d99cf8a7b708f1
    
    Closes tc39#218
    littledan committed Jan 25, 2019
    Configuration menu
    Copy the full SHA
    4e3f393 View commit details
    Browse the repository at this point in the history
  2. Normative: Split out BigInt formatting functions

    Two new methods are added to Intl.NumberFormat.prototype:
    - formatBigInt
    - formatBigIntToParts
    
    The earlier format/formatToParts methods are reverted to
    accept Number and not BigInt.
    littledan committed Jan 25, 2019
    Configuration menu
    Copy the full SHA
    7f68652 View commit details
    Browse the repository at this point in the history