Generates the smallest and largest numbers requiring $bits bits

@access private
@param int $bits
@return array
483142
function _generateMinMax($bits)
    {
        $bytes = $bits >> 3;
        $min = str_repeat(chr(0), $bytes);
        $max = str_repeat(chr(0xFF), $bytes);
        $msb = $bits & 7;
        if ($msb) {
            $min = chr(1 << ($msb - 1)) . $min;
            $max = chr((1 << $msb) - 1) . $max;
        } else {
            $min[0] = chr(0x80);
        }

        return array(
            'min' => new Math_BigInteger($min, 256),
            'max' => new Math_BigInteger($max, 256)
        );
    }
1328208
private long computeUndefNum(final Tristate[] bits) {
    long sum = 0;
    for (int i = bits.length - 1; i >= 0; i--)
      if (bits[i] == Tristate.UNDEF)
        sum += Math.pow(2, bits.length - 1 - i);
    return sum;
  }
67247
public function getVersionNumber($bits = null)
    {
        if (is_null($bits)) {
            return (int) str_replace('.', '', $this->version);
        }
        return implode('', $this->versionFromBits($bits));
    }
161375
public function encode($numbers)
    {
        if (!is_array($numbers)) {
            $numbers = [$numbers];
        }
        if ($this->signed) {
            $numbers = Signed::encodeBlock($numbers);
        }
        $digits = [];
        $bits = $this->bits;
        $cBit = $this->cBit;
        foreach ($numbers as $number) {
            do {
                $digit = ($number % $this->cBit);
                $number >>= $bits;
                $continue = ($number > 0);
                if ($continue) {
                    $digit += $cBit;
                }
                $digits[] = $digit;
            } while ($continue);
        }
        return $digits;
    }
78659
public function write_bit($b)
    {
        $b = $b ? 1 : 0;
        $shift = $this->bitcount % 8;
        $last = $shift === 0 ? 0 : array_pop($this->bits);
        $last |= ($b << $shift);
        array_push($this->bits, $last);
        $this->bitcount += 1;

        return $this;
    }
1255809
public function imaskn($bits) {
        assert(is_integer($bits) && $bits >= 0);
        if (assert_options(ASSERT_ACTIVE)) assert(!$this->negative());
        $mask = "";
        for($i = 0; $i < $bits; $i++)
            $mask .= "1";
        return $this->iand(new BN($mask, 2));
    }
1176119
public function getLeastSignificantBits()
    {
        if (!self::hasBigNumber()) {
            throw new Exception\UnsatisfiedDependencyException(
                'Cannot call ' . __METHOD__ . ' without support for large '
                . 'integers, since least significant bits is an unsigned '
                . '64-bit integer; Moontoast\Math\BigNumber is required'
                . '; consider calling getLeastSignificantBitsHex instead'
            );
        }

        $number = \Moontoast\Math\BigNumber::baseConvert(
            $this->getLeastSignificantBitsHex(),
            16,
            10
        );

        return new \Moontoast\Math\BigNumber($number);
    }
949798
def pack_bits( longbits ):
    """"""
    byte = longbits & (0x0101010101010101)
    byte = (byte | (byte>>7)) & (0x0003000300030003)
    byte = (byte | (byte>>14)) & (0x0000000f0000000f)
    byte = (byte | (byte>>28)) & (0x00000000000000ff)
    return byte
313728
public static function fromDecimal($size, $values = 0)
	{
		$size = min((int) $size, PHP_INT_SIZE);
		$values <<= PHP_INT_SIZE - $size;
		$bits = new BitArray($size);

		for ($i = 0; $i < PHP_INT_SIZE; $i++)
		{
			$bits->data[$i] = chr(($values & (0xff << (PHP_INT_SIZE - 8))) >> (PHP_INT_SIZE - 8));
			$values <<= 8;
		}

		return $bits;
	}
1022072
private BitSet toBitSet(int[] mapping) {
        BitSet hits = new BitSet();
        for (int v : mapping)
            hits.set(v);
        return hits;
    }
216333
@Override
	public int next(int bits) {
		long nextSeed = seed ^ (seed << 21);
		nextSeed ^= (nextSeed >>> 35);
		nextSeed ^= (nextSeed << 4);
		seed = nextSeed;
		return (int) (nextSeed & ((1L << bits) - 1));
	}
693137
public function setbit($key, $offset, $bit) {
        return $this->returnCommand(['SETBIT'], $key, [$key, $offset, $bit]);
    }
1283864
def bit_fields(&block)
      ("\x00".."\xff").each do |c|
        yield c
        yield c << c # x2
        yield c << c # x4
        yield c << c # x8
      end
    end
314477
public function appendBits(array $bits, Buffer $buffer)
    {
        $value = 0;
        foreach ($bits as $n => $bit) {
            $bit = $bit ? 1 : 0;
            $value |= $bit << $n;
        }
        $buffer->appendUint8($value);
    }
229038
private function bitwiseIn(
        $max,
        $matching
    ) {
        $result = [];
        for ($i = 1; $i <= $max; ++$i) {
            if ($i & $matching) {
                $result[] = $i;
            }
        }

        return $result;
    }
1206382
public function getNextSet(int $from) : int
    {
        if ($from >= $this->size) {
            return $this->size;
        }

        $bitsOffset = $from >> 5;
        $currentBits = $this->bits[$bitsOffset];
        $bitsLength = count($this->bits);
        $currentBits &= ~((1 << ($from & 0x1f)) - 1);

        while (0 === $currentBits) {
            if (++$bitsOffset === $bitsLength) {
                return $this->size;
            }

            $currentBits = $this->bits[$bitsOffset];
        }

        $result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits);
        return $result > $this->size ? $this->size : $result;
    }
338063
public static final long fromBitSet(final BitSet bits) {
    long value = 0L;
    for (int i = 0; i < bits.size(); i++) {
      value += bits.get(i) ? (1L << i) : 0L;
    }
    return value;
  }