[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
tkent at chromium.org
tkent at chromium.org
Thu Feb 4 21:34:26 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 0c758931e3b8eb2fbf97c738aaa8ae6ed961a21c
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Feb 1 02:33:14 2010 +0000
2010-01-31 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
[Windows] Fix a bug of round() with huge integral numbers
https://bugs.webkit.org/show_bug.cgi?id=34297
Fix a bug that round() for huge integral numbers returns incorrect
results. For example, round(8639999913600001) returns
8639999913600002 without this change though the double type can
represent 8639999913600001 precisely.
Math.round() of JavaScript has a similar problem. But this change
doesn't fix it because Math.round() doesn't use round() of
MathExtra.h.
* wtf/MathExtras.h:
(round): Avoid to do "num + 0.5" or "num - 0.5".
(roundf): Fixed similarly.
(llround): Calls round().
(llroundf): Calls roundf().
(lround): Calls round().
(lroundf): Calls roundf().
2010-01-31 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
[Win] Fix a bug of round() with huge integral numbers
https://bugs.webkit.org/show_bug.cgi?id=34297
Add a test case to call round(8639999913600001).
* fast/forms/input-valueasnumber-datetime-expected.txt:
* fast/forms/script-tests/input-valueasnumber-datetime.js:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 8711d82..ab2cc7d 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,27 @@
+2010-01-31 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ [Windows] Fix a bug of round() with huge integral numbers
+ https://bugs.webkit.org/show_bug.cgi?id=34297
+
+ Fix a bug that round() for huge integral numbers returns incorrect
+ results. For example, round(8639999913600001) returns
+ 8639999913600002 without this change though the double type can
+ represent 8639999913600001 precisely.
+
+ Math.round() of JavaScript has a similar problem. But this change
+ doesn't fix it because Math.round() doesn't use round() of
+ MathExtra.h.
+
+ * wtf/MathExtras.h:
+ (round): Avoid to do "num + 0.5" or "num - 0.5".
+ (roundf): Fixed similarly.
+ (llround): Calls round().
+ (llroundf): Calls roundf().
+ (lround): Calls round().
+ (lroundf): Calls roundf().
+
2010-01-29 Mark Rowe <mrowe at apple.com>
Sort Xcode projects.
diff --git a/JavaScriptCore/wtf/MathExtras.h b/JavaScriptCore/wtf/MathExtras.h
index 9ea57fd..a18949e 100644
--- a/JavaScriptCore/wtf/MathExtras.h
+++ b/JavaScriptCore/wtf/MathExtras.h
@@ -98,12 +98,25 @@ inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x
#if COMPILER(MSVC) || COMPILER(RVCT)
-inline long long llround(double num) { return static_cast<long long>(num > 0 ? num + 0.5 : ceil(num - 0.5)); }
-inline long long llroundf(float num) { return static_cast<long long>(num > 0 ? num + 0.5f : ceil(num - 0.5f)); }
-inline long lround(double num) { return static_cast<long>(num > 0 ? num + 0.5 : ceil(num - 0.5)); }
-inline long lroundf(float num) { return static_cast<long>(num > 0 ? num + 0.5f : ceilf(num - 0.5f)); }
-inline double round(double num) { return num > 0 ? floor(num + 0.5) : ceil(num - 0.5); }
-inline float roundf(float num) { return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); }
+// We must not do 'num + 0.5' or 'num - 0.5' because they can cause precision loss.
+static double round(double num)
+{
+ double integer = ceil(num);
+ if (num > 0)
+ return integer - num > 0.5 ? integer - 1.0 : integer;
+ return integer - num >= 0.5 ? integer - 1.0 : integer;
+}
+static float roundf(float num)
+{
+ float integer = ceilf(num);
+ if (num > 0)
+ return integer - num > 0.5f ? integer - 1.0f : integer;
+ return integer - num >= 0.5f ? integer - 1.0f : integer;
+}
+inline long long llround(double num) { return static_cast<long long>(round(num)); }
+inline long long llroundf(float num) { return static_cast<long long>(roundf(num)); }
+inline long lround(double num) { return static_cast<long>(round(num)); }
+inline long lroundf(float num) { return static_cast<long>(roundf(num)); }
inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); }
#endif
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b3b56b3..a514359 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -2,6 +2,18 @@
Reviewed by Darin Adler.
+ [Win] Fix a bug of round() with huge integral numbers
+ https://bugs.webkit.org/show_bug.cgi?id=34297
+
+ Add a test case to call round(8639999913600001).
+
+ * fast/forms/input-valueasnumber-datetime-expected.txt:
+ * fast/forms/script-tests/input-valueasnumber-datetime.js:
+
+2010-01-31 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
Fix valueAsNumber calculation for type=month.
https://bugs.webkit.org/show_bug.cgi?id=34304
diff --git a/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt b/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt
index 5d1ddd4..02828fb 100644
--- a/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasnumber-datetime-expected.txt
@@ -14,6 +14,7 @@ PASS setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00
PASS setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
PASS setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00Z"
+PASS setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1) is "275760-09-12T00:00:00.001Z"
PASS setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00Z"
Tests to set invalid values to valueAsNumber:
PASS input.value = ""; input.valueAsNumber = null; input.value is "1970-01-01T00:00Z"
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js b/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js
index 2abe7bf..325d0ea 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasnumber-datetime.js
@@ -26,6 +26,7 @@ shouldBe('setValueAsNumberAndGetValue(10000, 0, 1, 12, 0, 1, 0)', '"10000-01-01T
shouldBe('setValueAsNumberAndGetValue(794, 9, 22, 0, 0, 0, 0)', '""');
shouldBe('setValueAsNumberAndGetValue(1582, 9, 14, 23, 59, 59, 999)', '""');
shouldBe('setValueAsNumberAndGetValue(1582, 9, 15, 0, 0, 0, 0)', '"1582-10-15T00:00Z"');
+shouldBe('setValueAsNumberAndGetValue(275760, 8, 12, 0, 0, 0, 1)', '"275760-09-12T00:00:00.001Z"');
shouldBe('setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 0)', '"275760-09-13T00:00Z"');
// Date.UTC() of V8 throws an exception for the following value though JavaScriptCore doesn't.
// shouldBe('setValueAsNumberAndGetValue(275760, 8, 13, 0, 0, 0, 1)', '"275760-09-13T00:00:00.001Z"');
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list