Browse Source

fixed Std.parseInt("010")

Nicolas Cannasse 15 years ago
parent
commit
56182d8d68
1 changed files with 7 additions and 2 deletions
  1. 7 2
      std/flash/_std/Std.hx

+ 7 - 2
std/flash/_std/Std.hx

@@ -39,9 +39,14 @@
 	}
 
 	public static function parseInt( x : String ) : Null<Int> untyped {
-		var v = _global["parseInt"](x);
-		if( Math.isNaN(v) )
+		var v = _global["parseInt"](x, 10);
+		if( _global["isNaN"](v) ) {
+			if( x.charCodeAt(1) == 'x'.code ) {
+				v = _global["parseInt"](x);
+				if( !_global["isNaN"](v) ) return v; // fast isNaN
+			}
 			return null;
+		}
 		return v;
 	}