Repository navigation
Round Amount values directly instead of through an Intl formatter - #164
Open
jessealama wants to merge 1 commit into
Open
jessealama wants to merge 1 commit into
jessealama wants to merge 1 commit into
Conversation
|
The constructor and convertTo rounded a value by building a formatter object, calling FormatNumericToString, and parsing the formatted String back into a mathematical value and a digit count. RenderAmountValueWithPrecision now rounds the mathematical value itself and renders it. It handles the sign, rounds to the requested fraction or significant digits with the same candidate values that ToRawFixed and ToRawPrecision use, turns a negative value that rounds to zero into negative zero, and renders with the digit count that the formatted String used to carry, so the stored Strings are unchanged. CreateFormatterObject is gone. toString now renders through RenderAmountValue, which contains its former steps unchanged.
jessealama
force-pushed
the
round-mathematical-values
branch
from
September 29, 2026 23:37
2db4c7f to
147c8a1
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR splits out a chunk of #161 by changing how the Amount constructor and
.convertToround when precision options are given. Instead of building a formatter object, callingFormatNumericToString, and parsing the formatted String, we introduce a newRenderAmountValueWithPrecisionAO that rounds a mathematical value to the requested digits and renders it.CreateFormatterObjectis gone, andtoStringrenders through a newRenderAmountValue.This work is stacked on top of convert-options (#110). The sequence units PR (#161) will be rebuilt on top of it. The refactoring of
Number.prototype.toExponentialand the promotion of the rounding operations into ECMA-262 will follow as separate PRs.