Browse Source

php : fixed Std.parseFloat()

Franco Ponticelli 13 năm trước cách đây
mục cha
commit
d6a9c37d6a
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  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 {