-
Notifications
You must be signed in to change notification settings - Fork 107
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
Add more rounding modes #419
Comments
According to this table, "ceiling" rounds numbers toward positive infinity for all numbers; "up" rounds positive numbers toward positive infinity and negative numbers toward negative infinity. So, I think "half-up" is what 402 is doing. For example: (-1.5).toLocaleString("en", {maximumFractionDigits: 0})
// "-2" That would be "-1" for "half-ceiling". |
@sffc , right, sorry, my mistake |
Should Number#toPrecision, Number#toFixed and Number#toExponential also be updated? This will allow -BigDecimal- BigFloat ( with interface described in https://github.com/tc39/proposal-decimal ) to have the same abilitiy. Btw, for me, it is interesting to support only "half-down" and "half-up", seems. |
This proposal will set that type of precedent, but it is beyond the scope of what I plan to do. By the way, the main issue for discussion of rounding modes can be found in the proposal repo: tc39/proposal-intl-numberformat-v3#7 |
@sffc, Thanks for the answer, Well, my vote is for "Interpret Strings as Decimals" and the "bigfloat" library will do the rounding in my use case, and to keep the trailing zeros as is (no add, no remove). |
This is landed as part of Intl.NumberFormat v3. |
@littledan suggested adding rounding modes to the Intl.NumberFormat V3 proposal.
The spec currently says:
In other words, numbers are always rounded "half up". However, this is not always what users want.
ICU supports a longer list of rounding modes:
http://userguide.icu-project.org/formatparse/numbers/rounding-modes
The text was updated successfully, but these errors were encountered: