Переглянути джерело

[java/cs] Int64.compare fix. Closes #2317

Cauê Waneck 11 роки тому
батько
коміт
b97fe46205

+ 2 - 2
std/cs/_std/haxe/Int64.hx

@@ -127,9 +127,9 @@ using haxe.Int64;
 
 	public static inline function compare( a : Int64, b : Int64 ) : Int
 	{
-		return cast (a.asNative() - b.asNative());
+		return (a.asNative() < b.asNative()) ? -1 : (a.asNative() > b.asNative()) ? 1 : 0;
 	}
-	
+
 	public static function ucompare( a : Int64, b : Int64 ) : Int
 	{
 		if (a.asNative() < 0.mkNative())

+ 1 - 1
std/java/_std/haxe/Int64.hx

@@ -127,7 +127,7 @@ private typedef NativeInt64 = Int;
 
 	public static inline function compare( a : Int64, b : Int64 ) : Int
 	{
-		return cast(a.asNative() - b.asNative(), Int);
+		return (a.asNative() < b.asNative()) ? -1 : (a.asNative() > b.asNative()) ? 1 : 0;
 	}
 
 	public static function ucompare( a : Int64, b : Int64 ) : Int

+ 11 - 0
tests/unit/issues/Issue2317.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+import haxe.Int64;
+
+class Issue2317 extends unit.Test
+{
+	public function test()
+	{
+		var i = Int64.make(0xA, 0x828D97A8);
+		t( Int64.compare(i, Int64.ofInt(0) ) > 0 );
+	}
+}