소스 검색

use opPow to make Int32/64 implementations less retarded

Simon Krajewski 11 년 전
부모
커밋
62f745a1fa
2개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  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
 		// we might be on 64-bit php, so sign extend from 32-bit
 		return (x << extraBits) >> extraBits;
 		return (x << extraBits) >> extraBits;
 		#elseif python
 		#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
 		#else
 		return (x);
 		return (x);
 		#end
 		#end

+ 1 - 1
std/haxe/Int64.hx

@@ -62,7 +62,7 @@ class Int64 {
 		#elseif php
 		#elseif php
 			return i32php(i); // handle overflow of 32-bit integers correctly
 			return i32php(i); // handle overflow of 32-bit integers correctly
 		#elseif python
 		#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
 		#else
 			return i;
 			return i;
 		#end
 		#end