Simpler parseInt logic (bug 507993 followup, r=brendan,dvander).
authorMaks Verver <maksverver@geocities.com>
Tue, 11 Aug 2009 12:54:55 -0700
changeset 31500 6c02f6fd869dac1efd5ebf0ec79f998c21e92d3d
parent 31499 094d6d56f5d5dac7328a92c3165e683a9530970b
child 31501 7bbba24ea2ad724e7cd0195bb5eef200267691b7
child 31503 a89a3bb28cd7eea855df855b44509fa8fb7d9866
push idunknown
push userunknown
push dateunknown
reviewersbrendan, dvander
bugs507993
milestone1.9.2a1pre
Simpler parseInt logic (bug 507993 followup, r=brendan,dvander).
js/src/jsnum.cpp
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -203,26 +203,21 @@ ParseInt(JSContext* cx, JSString* str)
     return d;
 }
 
 static jsdouble FASTCALL
 ParseIntDouble(jsdouble d)
 {
     if (!JSDOUBLE_IS_FINITE(d))
         return js_NaN;
-
-    /* Don't preserve -0, because js_strtointeger doesn't. */
-    if (d == 0)
-        return 0;
     if (d > 0)
         return floor(d);
-    d = ceil(d);
-
-    /* ceil does not seem to return -0 if not given -0. */
-    return (d == 0) ? -0.0 : d;
+    if (d < 0)
+    	return -floor(-d);
+    return 0;
 }
 #endif
 
 const char js_Infinity_str[]   = "Infinity";
 const char js_NaN_str[]        = "NaN";
 const char js_isNaN_str[]      = "isNaN";
 const char js_isFinite_str[]   = "isFinite";
 const char js_parseFloat_str[] = "parseFloat";