Commit 1bc9a21e authored by lrn@chromium.org's avatar lrn@chromium.org

Sorry, this should have gone to http://codereview.chromium.org/391014

I added some tests and swapped the lhs and rhs of the && operator in v8natives.js as requested.

Review URL: http://codereview.chromium.org/384132


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3319 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9a545949
......@@ -3387,8 +3387,7 @@ static Object* Runtime_StringParseInt(Arguments args) {
NoHandleAllocation ha;
CONVERT_CHECKED(String, s, args[0]);
CONVERT_DOUBLE_CHECKED(n, args[1]);
int radix = FastD2I(n);
CONVERT_SMI_CHECKED(radix, args[1]);
s->TryFlattenIfNotFlat();
......
......@@ -95,8 +95,8 @@ function GlobalParseInt(string, radix) {
// they make parseInt on a string 1.4% slower (274ns vs 270ns).
if (%_IsSmi(string)) return string;
if (IS_NUMBER(string) &&
((string < -0.01 && -1e9 < string) ||
(0.01 < string && string < 1e9))) {
((0.01 < string && string < 1e9) ||
(-1e9 < string && string < -0.01))) {
// Truncate number.
return string | 0;
}
......
......@@ -36,9 +36,12 @@ assertEquals(-63, parseInt(' -077'));
assertEquals(3, parseInt('11', 2));
assertEquals(4, parseInt('11', 3));
assertEquals(4, parseInt('11', 3.8));
assertEquals(0x12, parseInt('0x12'));
assertEquals(0x12, parseInt('0x12', 16));
assertEquals(0x12, parseInt('0x12', 16.1));
assertEquals(0x12, parseInt('0x12', NaN));
assertEquals(12, parseInt('12aaa'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment