tc39 / tc39/proposal-decimal

BigInt + Scale

Open
#32 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
638
Forks
20
PR merge metrics
No merged PRs in 30d

Description

The most simple implementation of BigDecimal would be a record with two fields: a BigInt and a scale (power of 10). The industry already uses something along these lines for currency amounts, which are often stored as a BigInt number of "micros".

If we're only concerned about representation, and not math, an alternative to the BigDecimal proposal altogether would be to establish a precedent for how to represent the BitInt/Scale pair. For example, we could add a .format overload to Intl.NumberFormat method that takes an object literal with a BigInt and a scale. Something like,

new Intl.NumberFormat().format({
  mantissa: // a BigInt
  scale: // a power of 10 (probably a Number)
});

We could establish that convention as how BigDecimals are represented in the language, without actually introducing a BitInt type.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the proposed BigInt-and-scale representation and the suggested Intl.NumberFormat.format overload in this issue. No file or test is identified, and completion would require deciding whether this representation convention should replace or complement the BigDecimal proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
internationalization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.