1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- declare(strict_types = 1);
- namespace BaconQrCode\Common;
- final class BitUtils
- {
- private function __construct()
- {
- }
-
- public static function unsignedRightShift(int $a, int $b) : int
- {
- return (
- $a >= 0
- ? $a >> $b
- : (($a & 0x7fffffff) >> $b) | (0x40000000 >> ($b - 1))
- );
- }
-
- public static function numberOfTrailingZeros(int $i) : int
- {
- $lastPos = strrpos(str_pad(decbin($i), 32, '0', STR_PAD_LEFT), '1');
- return $lastPos === false ? 32 : 31 - $lastPos;
- }
- }
|