Преглед изворни кода

php : fixed Std.parseFloat()

Franco Ponticelli пре 13 година
родитељ
комит
d6a9c37d6a
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      std/php/_std/Std.hx

+ 4 - 1
std/php/_std/Std.hx

@@ -46,8 +46,11 @@
 			return x.substr(0, 2).toLowerCase() == "0x" ? __php__("(int) hexdec(substr($x, 2))") : __php__("intval($x)");
 	}
 
+	static var NAN : Float = untyped __call__("acos", 1.01);
 	public static function parseFloat( x : String ) : Float {
-		return untyped __php__("is_numeric($x) ? floatval($x) : acos(1.01)");
+		var v : Float = untyped __call__("floatval", x),
+			s = "" + v;
+		return x.substr(0, s.length) == s ? v : NAN;
 	}
 
 	public static function random( x : Int ) : Int {