Created
December 18, 2015 08:36
-
-
Save mikeshiyan/e2c2e682c47962bf8af5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Analogue of JS Unsigned Right Shift Operator (>>>). | |
*/ | |
/** | |
* Shifts $int in binary representation $steps (< 32) bits to the right, | |
* discarding bits shifted off, and shifting in zeros from the left. | |
* | |
* @param int $int | |
* @param int $steps | |
* | |
* @return int | |
*/ | |
function unsigned_right_shift($int, $steps) { | |
return ($int >> $steps) & (pow(2, 32 - $steps) - 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment