[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
Sun Oct 31 21:17:22 PDT 2010


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





--- Comment #18 from Gavin Barraclough <barraclough at apple.com>  2010-10-31 21:17:21 PST ---
I think this is the wrong fix for this problem – I think there is actually a bug here that we should be fixing, and adopting non-spec compliant behavior as a bug work-around wouldn't be the right solution.

All the code in HTMLInputElement is already written using double precision, which should be sufficient to obtain the desired results.  Looking through the code, it looks like the accuracy error is introduced by this line in HTMLInputElement::applyStep:

>    newValue = base + round((newValue - base) / step) * step;

I believe this ensures that after stepping the value will snap to the nearest number that fits the formula (base + step * I, for some integer I).  But looking through the defined algorithm for stepUp() in section 4.10.7.3 of the HTML5 spec I can't find any reference to the behavior.  Unless I'm missing something, this is also a bug – this should not be happening.  Assuming I'm reading the spec correctly, I think the real fix for this bug is probably just to remove this line of code.

I've not yet tested this, it is possible there is more than one place that errors are being introduced, but this is the only one I can spot.  Fundamentally 5.005 + (0.005 * 2) (which I believe is the calculation the spec requires us to perform) evaluated at double precision (which is what we're doing) produces a result that prints as desired using numberToString.  Any inaccuracies being introduced by errors in our code are bugs that should be fixed.  Once we are producing the correct value, per the spec, no changes to to-string conversion should be necessary.

cheers,
G.

-- 
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