[Webkit-unassigned] [Bug 9697] parseInt results may be inaccurate for numbers greater than 2^53

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jul 15 23:59:12 PDT 2007


http://bugs.webkit.org/show_bug.cgi?id=9697





------- Comment #10 from aroben at apple.com  2007-07-15 23:59 PDT -------
(From update of attachment 15527)
+            if (s[p] == 'e') {
+                char shortenedString[p];
+
+                memcpy(shortenedString, s.ascii(), p);
+                shortenedString[p] = '0';
+
+                number = kjs_strtod(shortenedString + firstDigitPosition, 0);

I see two errors here:

1) shortenedString[p] = '0' should be shortenedString[p] = '\0'

2) The declaration of shortenedString won't compile with compilers other than
GCC since it relies on a GCC extension.

You can actually avoid allocating a new string entirely by doing this:

+            if (s[p] == 'e') {
+                s[p] = '\0';
+
+                number = kjs_strtod(s + firstDigitPosition, 0);
+                s[p] = 'e';


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



More information about the webkit-unassigned mailing list