Răsfoiți Sursa

use opPow to make Int32/64 implementations less retarded

Simon Krajewski 11 ani în urmă
părinte
comite
62f745a1fa
2 a modificat fișierele cu 2 adăugiri și 3 ștergeri
  1. 1 2
      std/haxe/Int32.hx
  2. 1 1
      std/haxe/Int64.hx

+ 1 - 2
std/haxe/Int32.hx

@@ -192,8 +192,7 @@ abstract Int32(Int) from Int to Int {
 		// we might be on 64-bit php, so sign extend from 32-bit
 		return (x << extraBits) >> extraBits;
 		#elseif python
-		// thx to http://stackoverflow.com/questions/385572/need-help-typecasting-in-python#385583
-		return (x + python.Syntax.pythonCode("2**31")) % python.Syntax.pythonCode("2**32 - 2**31");
+		return (x + python.Syntax.opPow(2, 31)) % python.Syntax.opPow(2, 32) - python.Syntax.opPow(2, 31);
 		#else
 		return (x);
 		#end

+ 1 - 1
std/haxe/Int64.hx

@@ -62,7 +62,7 @@ class Int64 {
 		#elseif php
 			return i32php(i); // handle overflow of 32-bit integers correctly
 		#elseif python
-			return (i + python.Syntax.pythonCode("2**31")) % python.Syntax.pythonCode("2**32 - 2**31");
+			return (i + python.Syntax.opPow(2, 31)) % python.Syntax.opPow(2, 32) - python.Syntax.opPow(2, 31);
 		#else
 			return i;
 		#end