Browse Source

Merge pull request #2395 from Herschel/development

Fix Int32 post-decrement operator
Simon Krajewski 11 years ago
parent
commit
5e4c296d54
2 changed files with 11 additions and 2 deletions
  1. 10 1
      std/haxe/Int32.hx
  2. 1 1
      tests/unit/unitstd/haxe/Int32.unit.hx

+ 10 - 1
std/haxe/Int32.hx

@@ -41,7 +41,7 @@ abstract Int32(Int) from Int to Int {
 		return this = clamp(--this);
 
 	@:op(A--) inline public function postDecrement():Int32 {
-		var ret = this++;
+		var ret = this--;
 		this = clamp(this);
 		return ret;
 	}
@@ -148,6 +148,15 @@ abstract Int32(Int) from Int to Int {
 	@:to public inline function toFloat():Float
 		return this;
 
+	/**
+		Compare two Int32 in unsigned mode.
+	**/
+	public static function ucompare( a : Int32, b : Int32 ) : Int {
+		if( a < 0 )
+			return b < 0 ? ( ~b - ~a ) : 1;
+		return b < 0 ? -1 : (a - b);
+	}
+
 	#if php
 	static var extraBits : Int = untyped __php__("PHP_INT_SIZE") * 8 - 32;
 	#end

+ 1 - 1
tests/unit/unitstd/haxe/Int32.unit.hx

@@ -6,7 +6,7 @@ var a:haxe.Int32 = 0x7fffffff;
 a++ == max;
 a == min;
 a-- == min;
-a = max;
+a == max;
 ++a == min;
 --a == max;