public function range(int $start, int $length): string
    {
        if (!$length) {
            return "0";
        }
        if ($start + $length > $this->numBits()) {
            throw new \OutOfBoundsException("Not enough bits.");
        }
        $bits = gmp_init(0);
        $idx = $start;
        $end = $start + $length;
        while (true) {
            $bit = $this->testBit($idx) ? 1 : 0;
            $bits |= $bit;
            if (++$idx >= $end) {
                break;
            }
            $bits <<= 1;
        }
        return gmp_strval($bits, 10);
    }
public function range(int $start, int $length): string
    {
        if (!$length) {
            return "0";
        }
        if ($start + $length > $this->numBits()) {
            throw new \OutOfBoundsException("Not enough bits.");
        }
        $bits = gmp_init(0);
        $idx = $start;
        $end = $start + $length;
        while (true) {
            $bit = $this->testBit($idx) ? 1 : 0;
            $bits |= $bit;
            if (++$idx >= $end) {
                break;
            }
            $bits <<= 1;
        }
        return gmp_strval($bits, 10);
    }
public function range ( int $ start , int $ length ) : string { if ( ! $ length ) { return "0" ; } if ( $ start + $ length > $ this -> numBits ( ) ) { throw new \ OutOfBoundsException ( "Not enough bits." ) ; } $ bits = gmp_init ( 0 ) ; $ idx = $ start ; $ end = $ start + $ length ; while ( true ) { $ bit = $ this -> testBit ( $ idx ) ? 1 : 0 ; $ bits |= $ bit ; if ( ++ $ idx >= $ end ) { break ; } $ bits <<= 1 ; } return gmp_strval ( $ bits , 10 ) ; }
Get range of bits.

@param int $start Index of first bit
@param int $length Number of bits in range
@throws \OutOfBoundsException
@return string Integer of $length bits
Get range of bits .