Jelajahi Sumber

[php] Fix unsign right shift (#7571)

* [php] Fix right unsign shift

* Add test for unsign right shift [php]
flashultra 6 tahun lalu
induk
melakukan
d2ab64c59b
2 mengubah file dengan 9 tambahan dan 1 penghapusan
  1. 1 1
      std/php/Boot.hx
  2. 8 0
      tests/unit/src/unit/issues/Issue7533.hx

+ 1 - 1
std/php/Boot.hx

@@ -480,7 +480,7 @@ class Boot {
 		if (right == 0) {
 			return left;
 		} else if (left >= 0) {
-			return (left >> right);
+			return ((left >> right) & ~(1 << ( 8*Const.PHP_INT_SIZE-1 ) >> (right-1)));
 		} else {
 			return (left >> right) & (0x7fffffff >> (right - 1));
 		}

+ 8 - 0
tests/unit/src/unit/issues/Issue7533.hx

@@ -0,0 +1,8 @@
+package unit.issues;
+
+class Issue7533 extends unit.Test {
+	function test() {
+      var bint:Int = 0xB425B745;
+      eq( (bint>>>20), 0xB42);
+	}
+}