Skip to content
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

Existing decimal usage in the web platform #80

Open
annevk opened this issue May 22, 2023 · 5 comments
Open

Existing decimal usage in the web platform #80

annevk opened this issue May 22, 2023 · 5 comments

Comments

@annevk
Copy link
Member

annevk commented May 22, 2023

I stumbled across https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/Decimal.cpp today. This is apparently used for <input>, see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/html/InputType.cpp.

I think a goal of this effort needs to be that it can serve as a replacement of this existing Decimal class (or expose the existing class to script).

This relates to #4 but seemed different enough to warrant its own issue.

@jessealama
Copy link
Collaborator

I didn't know about this use of decimal numbers inside WebKit -- thanks for the tip!

@littledan
Copy link
Member

Interesting, looks like Chrome has this as well: https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:third_party/blink/renderer/platform/wtf/decimal.h

Looks like this operates with a 16-bit exponent and 64-bit mantissa. This probably continues the pattern that I noted in a decimal presentation a while ago: Everyone has different decimal details, and users don't run into these edge cases and don't care.

@littledan
Copy link
Member

Oh, I guess Mozilla contains the same code, used in the same way for input elements! https://searchfox.org/mozilla-central/search?q=symbol:T_mozilla%3A%3ADecimal&redirect=false

@jessealama
Copy link
Collaborator

Are these bits of the respective code bases under active development? It seems to me that this might be one of those things that one gets right once, and then it's good for a long time. I'd be happy to contact the developers to tell them about IEEE 754 Decimal128, which is the approach that we've settled on for proposal-decimal. I'd love it if there could be some tie-in between the JS engine world and the UI part of a browser. It seems possible.

(Relatedly, but adjacent:

Coming from the UI angle, one thing that occurs to me would be to have some built-in stepper functionality in the proposal-decimal. I.e. an API function that, starting with, say, the decimal 1.28, would yield 1.29, 1.30 (notice the trailing zero), 1.31, etc. Same for a step-down function. This is actually part of IEEE 754 Decimal128 that currently doesn't exist in the proposal-decimal API.)

@annevk
Copy link
Member Author

annevk commented Aug 13, 2024

<input type=number> is not actively undergoing changes. It's interesting that https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number) describes it in terms of floating-point, which is obviously not what implementations are doing. Not entirely sure how that mismatch came to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants