[Webkit-unassigned] [Bug 48308] Too precise serialization from floating point number to string for "number" input elements

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 28 20:53:11 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=48308





--- Comment #9 from Dai Mikurube <dmikurube at google.com>  2010-10-28 20:53:10 PST ---
(In reply to comment #8)
Thanks for your comments, Gavin.

Unfortunately, casting to float and printing with numberToString() don't work. The original numberToString() try printing numbers with 16-17 digits. Then, for example,
> setValueAsNumberAndGetValue(-1.2)
is printed as
> -1.2000000476837158
with casting to float.

To solve the first problem (like 5.015000000000001), we have to
    1. limit the printed digits in the HTML context, or
    2. make stepUp() and stepDown() more and more precise

But [1.] is not compliant with HTML5 2.5.4.3 :
> The best representation of the number n as a floating point number is the string obtained from applying the JavaScript operator ToString to n.
Yes, it is a difficult problem, I think. The difficulty comes from
    A. single-precision in HTML5, but double-precision in JavaScript, and
    B. numeric errors from computing stepUp and stepDown with floating point numbers.
A and B looks like incompatible with HTML5 2.5.4.3. [2.] is, of course, naturally challenging.

What do you think about adding another numberToString with a different signature without rewriting the original numberToString? It's to avoid rewriting the original numberToString, but also to make it easy to keep following with future changes on the original numberToString. My first idea here was to print with limited digits by the same logic as JavaScript's ToString.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list