-
Notifications
You must be signed in to change notification settings - Fork 2
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
Proposal for stage 0 #1
Comments
For the record, an initial discussion has already happened in this thread of javascript-globalization@googlegroups.com mailing list. |
@rwaldron, FWIW I also think the currency arguments of |
@ehoogerbeets, @caridy, I'm confused why you believe my proposed Rounding methods like half-up, half-down, or any other different methods cannot be selected by the API, neither per locale basis, neither per formatting style basis (e.g., formatting numbers vs. formatting currencies vs. etc). Please, correct me if I'm wrong. All the locale-differences are kept unchanged with or without my proposed round option. For example, (a) the digit where the rounding takes place using minumumFractionDigits, or maximumFractionDigits, or minumumSignificantDigits and maximumSignificantDigits is kept unchanged; (b) the currency-dependent-digit where the rounding takes place (e.g., USD has 2 decimal digits, JPY has 0 decimal digits, CLF has 4 decimal digits, etc) is kept unchanged, (c) the fact some currencies have roundings based on available coins is unchanged with or without my proposed round option. The point is: if you want to use half-up (i.e., Math.ceil) on your roundings, how do you do it? Again, the formatter always rounds whether or not you like it. |
On chrome, the three digits result is an implementation bug. Ecma-402 says on 11.1.1.1 |
@nciric ☝️ FYI |
UTS#35 Rounding has rules for that. Rounding currencies per 5 cents coins is really easy using a pattern like "0.05". |
Ok, let me re-iterate my position:
|
Can you clarify what do you consider to be a specific formatting rules? |
I came here by way of seeing @ericf's Intl talk at React.js Conf. We chatted, yesterday afternoon, about our use case for rounding options in I work on a product used by people who can follow other people. Follower counts can climb high enough that we must abbreviate them. When abbreviating them, we have two requirements:
Adding an I invite you to comment on this proposal for an abbreviation API in var number = 7654321;
console.log(new Intl.NumberFormat('en-US', {
abbreviationThreshold: 1e6,
abbreviationRoundingMethod: Intl.NumberFormat.ROUND_DOWN,
maximumFractionDigits: 1,
maximumSignificantDigits: 3,
}).format(number));
// → 7.6M
console.log(new Intl.NumberFormat('ja-JP', {
abbreviationThreshold: 1e6,
abbreviationRoundingMethod: Intl.NumberFormat.ROUND_DOWN,
maximumFractionDigits: 1,
maximumSignificantDigits: 3
}).format(number));
// → 765万 According to the usual rules of Also, note that in some locales, such as If you haven't already clicked through to the proposal, here's a link straight to an explanation of the proposed rounding modes (based on prior art from java.math). |
@ericf, thanks for the referral/direction. @steveluscher, thanks for sharing your use case, where you need to specify a rounding mode.
I'm assuming the proposed
About the possible rounding values... (a) Rounding functions belong to the Math realm, therefore the preferred object is Math instead of Intl.NumberFormat.fns (anyone can correct me if I'm wrong), (b) I'm not sure Math provides all the options you describe. @rwaldron, can provide his thoughts about it...
You need to be able to specify an abbreviated display mode (to keep track of this, I've added it to the above description as one more sidenote that need action to be taken). The code logic that handles the threshold switch (example below) could live in user land. output = value < threshold ? normalFormatter( value ) : abbreviatedFormatter( value ); |
@rxaviers yes, the ROUND_ bits shouldn't belong to the |
Looking into this example: Intl.NumberFormat('en').format(1.1119) // yields
"1.1112" It looks to me that the rounding is already done, changing the supplied number. I would appreciate having these features:
|
@bsrdjan that's not the result I'm getting, this is what I get in FF and Chrome:
|
sorry, correct, mistake in my post, is |
@rxaviers came across your proposal for different rounding methods for Intl. - |
@smoholkar no, this proposal hasn't get any traction. |
@caridy oh. That's a good proposal actually. Hope we get that feature in future soon. |
It would be very useful feature of Intl. |
Goal
Poll for discussion.
Sidenotes raised in this discussion - needs action to be taken
0.05
).The text was updated successfully, but these errors were encountered: