Browse Source

php: attempt at fixing Math.exp specifications

Franco Ponticelli 12 years ago
parent
commit
d711eff4c2
2 changed files with 9 additions and 2 deletions
  1. 8 1
      std/php/_std/Math.hx
  2. 1 1
      std/php/_std/Std.hx

+ 8 - 1
std/php/_std/Math.hx

@@ -33,7 +33,14 @@
 	public static function cos(v : Float) : Float      { return untyped __call__("cos", v); }
 	public static function atan2(y : Float,x : Float) : Float  { return untyped __call__("atan2", y, x); }
 	public static function tan(v : Float) : Float      { return untyped __call__("tan", v); }
-	public static function exp(v : Float) : Float      { return untyped __call__("exp", v); }
+	public static function exp(v : Float) : Float      {
+		if(v == POSITIVE_INFINITY)
+			return POSITIVE_INFINITY;
+		else if(v == NEGATIVE_INFINITY)
+			return 0.0;
+		else
+			return untyped __call__("exp", v);
+	}
 	public static function log(v : Float) : Float      { return untyped __call__("log", v); }
 	public static function sqrt(v : Float) : Float     { return untyped __call__("sqrt", v); }
 	public static function round(v : Float) : Int      { return untyped __call__("(int) floor", v + 0.5); }

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

@@ -32,7 +32,7 @@
 	public static function int( x : Float ) : Int {
 		var i : Int = untyped __call__("fmod", x, 0x80000000) & 0xffffffff;
 		if (untyped i & 0x80000000)
-        	i = -((~i & 0xFFFFFFFF) + 1);
+        	i = -((~i & 0xffffffff) + 1);
         return i;
 	}