diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2010-04-07 16:12:45 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2010-04-07 16:55:17 (GMT) |
commit | 64f5b0cfdcbeacb4fe0aaf03810efa7572c858cc (patch) | |
tree | 8bfce891075f6631eab4a611e0f59e930100e2d3 /src/3rdparty | |
parent | 473dfcdf47372860f6d70264755050a7a1bbd493 (diff) | |
download | Qt-64f5b0cfdcbeacb4fe0aaf03810efa7572c858cc.zip Qt-64f5b0cfdcbeacb4fe0aaf03810efa7572c858cc.tar.gz Qt-64f5b0cfdcbeacb4fe0aaf03810efa7572c858cc.tar.bz2 |
Updated JavaScriptCore from /home/khansen/dev/qtwebkit-qtscript-integration to javascriptcore-snapshot-07042010 ( da4f912a2f648d518628e1066dace894d1da7081 )
[Windows] Fix a bug of round() with huge integral numbers
https://bugs.webkit.org/show_bug.cgi?id=34297
Diffstat (limited to 'src/3rdparty')
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog | 24 | ||||
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h | 25 | ||||
-rw-r--r-- | src/3rdparty/javascriptcore/VERSION | 2 |
3 files changed, 44 insertions, 7 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog index 68411ab..cfad1ea 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog +++ b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog @@ -1,3 +1,27 @@ +2010-01-31 Kent Tamura <tkent@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-27 Anton Muhin <antonm@chromium.org> Reviewed by Darin Adler. diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h index 9ea57fd..a18949e 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h +++ b/src/3rdparty/javascriptcore/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/src/3rdparty/javascriptcore/VERSION b/src/3rdparty/javascriptcore/VERSION index 581837e..a96e22f 100644 --- a/src/3rdparty/javascriptcore/VERSION +++ b/src/3rdparty/javascriptcore/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 8662fcc9bb1d374fa10114fe629f18290641cccc + da4f912a2f648d518628e1066dace894d1da7081 |