[Webkit-unassigned] [Bug 25027] New: JavaScript parseInt wrong on negative numbers
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Apr 3 08:16:35 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=25027
Summary: JavaScript parseInt wrong on negative numbers
Product: WebKit
Version: 528+ (Nightly build)
Platform: Macintosh
OS/Version: Mac OS X 10.5
Status: UNCONFIRMED
Severity: Normal
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: mihnea at adobe.com
Hello,
I used a simple test script for JavaScript parseInt function:
<html>
<head>
<script>
function testParseInt() {
var result = -0.6;
alert(parseInt(result));
}
</script>
</head>
<body>
<input type="button" onclick="testParseInt()" value="TestEval1">
</body>
</html>
However, instead of displaying 0, it display -1. The problem seems to be in:
JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp function globalFuncParseInt
at line:
if (isfinite(d))
return jsNumber(exec, floor(d));
I think it should be:
if (isfinite(d))
return jsNumber(exec, (d > 0) ? floor(d) : ceil(d));
I tested with latest WebKit build 42198 on Leopard and the alert displays -1
instead of 0.
FF3/Opera/IE8(Win) display 0 on the same test.
I can provide a patch but i was not sure where to put the layout test. Is it ok
to change LayoutTests/fast/js/numeric-conversion-expected by adding test for
this case or should i add another different unit test?
Regards,
Mihnea
--
Configure bugmail: https://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