PHP implements left shift and unsigned right shift (>>>in js)

Shifting includes left shift with sign (<<), right shift with sign (>>), right shift without sign (>>)

Shifting includes signed left shift (<<), signed right shift (>>), and unsigned right shift (>>>). js supports three types of shifts, while PHP only supports the first two types of shifts (the third is not found). PHP just needs to perform unsigned right shift,


The reason why the result of PHP left shift is inconsistent with that of JS left shift is that JS is 32-bit, but PHP is 64 bit, so conversion is required

$n is the value and $m is the offset

 function zy32($n,$m){     return (($n << $m) << 32) >> 32;}


It is implemented here. Look at the results first

Move the number a to the right unsigned by n bits

 function uright($a, $n) {     $c = 2147483647>>($n-1);     return $c&($a>>$n); }


comment

Your writing is very clear, which makes it easy for me to understand your point of view.