tc39 / tc39/proposal-amount

Construction of canonical exponential strings is overly cumbersome

Open
#113 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
58
Forks
12
Avg merge
2h 35m
Merged PRs (30d)
2

Description

https://github.com/tc39/proposal-amount/pull/112#discussion_r3270010468

I see four uses of RenderInExponentialNotation:

  • in the Amount constructor, with the fields of an Intl MV Record derived from a FormatNumericToString output string
  • in Amount.prototype.convertTo (here), with the fields of an Intl MV Record derived from a FormatNumericToString output string
  • in Amount.prototype.toString, with the fields of an Intl MV Record derived from a Number
  • in Amount.prototype.toString, with the fields of an Intl MV Record derived from a BigInt::toString(v, 10) decimal digit sequence (where those fields could alternatively be defined directly by counting the digits in the decimal representation of _v_, e.g. ceiling(log10(abs(_v_) + 1)) or a named equivalent)

The uses of FormatNumericToString seem to be necessary, but it occurs to me that we could probably remove a lot of translation, e.g. carrying non-exponential decimal strings from FormatNumericToString and maybe-exponential decimal strings from Number::toString all the way to the exponent-ensuring and decimal-point-shifting work of RenderInExponentialNotation without passing through non-string intermediaries.

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 with the linked PR discussion and trace the four uses of RenderInExponentialNotation in the Amount constructor, Amount.prototype.convertTo, and Amount.prototype.toString. Compare the FormatNumericToString, Number::toString, and BigInt::toString paths; done means reducing unnecessary translation while preserving canonical exponential-string behavior across all listed call sites.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.