WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
34462
Fix a bug that Math.round() returns incorrect results for huge integers
https://bugs.webkit.org/show_bug.cgi?id=34462
Summary
Fix a bug that Math.round() returns incorrect results for huge integers
Kent Tamura
Reported
2010-02-01 19:37:14 PST
Fix a bug that Math.round() retunrs incorrect results for huge integers
Attachments
Patch
(3.64 KB, patch)
2010-02-01 19:38 PST
,
Kent Tamura
darin
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Kent Tamura
Comment 1
2010-02-01 19:38:48 PST
Created
attachment 47901
[details]
Patch
Darin Adler
Comment 2
2010-02-01 19:46:59 PST
Comment on
attachment 47901
[details]
Patch How about this instead? - if (signbit(arg) && arg >= -0.5) - return jsNumber(exec, -0.0); - return jsNumber(exec, floor(arg + 0.5)); + double integer = ceil(arg); + return jsNumber(exec, integer - (integer - arg > 0.5));
Darin Adler
Comment 3
2010-02-01 19:47:56 PST
Comment on
attachment 47901
[details]
Patch Patch seems fine. But you should consider my patch with ceil that avoids the need for the separate if statement. You could use ? : instead of the way I did it. Or use my code exactly as is (as long as it passes your tests).
Darin Adler
Comment 4
2010-02-01 19:48:58 PST
Would be nice to have tests cases for the maximum and minimum double values as well to make sure they don't turn into infinity when rounded.
Kent Tamura
Comment 5
2010-02-01 20:51:16 PST
Thank you for the quick review. Ok, I followed the proposed code, and add test cases for minimum/maximum values. Landed as
r54197
and
r54198
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug