-
Notifications
You must be signed in to change notification settings - Fork 71
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
Format specifier for BigInt #148
Comments
Keep in mind that Node.js is currently violating the spec for the So I think, we may not even need a spec change. |
Actually upon deeper investigation So I think we'd actually need a console spec change, I see two options:
|
I believe the issue isn't
I would prefer to define On the other hand, |
My two cents: agreed handling BigInt is good. Probably https://console.spec.whatwg.org/#formatter step 3.2 should add another special-case for BigInt, like it currently does for Symbol. Also the third column of https://console.spec.whatwg.org/#formatting-specifiers should be updated I guess, not sure how though. |
Maybe add a additional column before it for the source type. This could also include the Symbol special case. |
Options (1) and (2) do not look mutually exclusive: the |
If new specifier is necessary for BigInt, the proposed |
In Chrome, we just allowed If this group decides we need different behavior, we can align. |
I don't mind expanding Paul, does Chrome have interest in also supporting Do we have input from Firefox, Safari, or Edge? |
In Chrome we support both and both of them support BigInt. |
@ak239 thanks for confirming. Gerrit wasn't loading well for me on Muni. |
@paulirish @ak239 Thanks. Now I confirmed |
The Chrome implementation appends the |
Thank you all for your comments. Do you think it should be added to the specification that |
Sorry for the delay on getting to this. Plan on carving out time for this soon if nobody gets to it first. |
What is the correct display when passing BigInt to Chrome/96.0.4664.110 console.log('%f', 10n) // NaN
parseFloat(10n, 10) // 10
parseFloat(10n) // 10 Firefox/97.0 console.log('%f', 10n) // undefined
parseFloat(10n, 10) // 10
parseFloat(10n) // 10 |
@domfarolino So all major browsers support However, each browser differently work for I think that %d and %i should be defined as standards to support the format specifier of BigInt. But I’m still not sure that |
Thanks for following-up on this and reminding be about this thread. I'm trying to figure out what action needs to be taken based on the desired result here. Years ago Chrome would output However, Firefox and Safari seem to have prettier outputs by actually listing all the integers without scientific notation (and Safari even puts commas in the right places etc.). If we want this special pretty output for BigInts, then I think we need to add the special case for Does this sound right to everyone, and does anyone have strong opinions on just delegating to |
As an alternative , we could specify |
Doesn't the spec already do this? Since we don't special-case anything now, the spec will just call %parseInt()% on BigInts for the So I guess I'm trying to figure out if we agree that the current spec just passes BigInts to |
I think the behavior of going through |
Right. I'm personally a fan of less specifiers and instead special-casing BigInt support for |
Also, what's the status of BigDecimal? If it were to be added, would we have to add another special case? |
BigDecimal is stage 1 apparently: https://github.com/tc39/proposal-decimal#ecma-tc39-javascript-decimal-proposal. I guess I was just assuming we could squeeze it into the |
And you could continue using those, you'd just get the behavior of |
Chrome 68 supports BigInt and also Node.js v10 supports it with
--harmony-bigint
flag. But console.log doesn't support BigInt in them.Chrome 68
Node.js v10.7.0 with
--harmony-bigint
I think expected result is
However, spec shows
%d or %i
uses%parseInt%(element, 10)
for type conversion.What specifier is the best for BigInt? Has this already been discussing?
The text was updated successfully, but these errors were encountered: