Converts a BigInteger to a binary string.

@return int
766874
public function toInteger()
    {
        if (0 === gmp_cmp($this->value, gmp_init(0))) {
            return '';
        }

        $temp = gmp_strval(gmp_abs($this->value), 10);

        return (int) $temp;
    }
500792
public function getIntegerPart()
	{
		if ( ! $this->getIsDecimal() ) return $this->_value;
		return substr( $this->_value, 0, strpos( $this->_value, "." ) );
	}
280828
public function readIntBeBySize($size)
    {
        if ($size === self::UNSIGNED_CHAR_LENGTH) {
            return $this->readInt8();
        }
        if ($size === self::UNSIGNED_SHORT_LENGTH) {
            return $this->readInt16Be();
        }
        if ($size === self::UNSIGNED_INT24_LENGTH) {
            return $this->readInt24Be();
        }
        if ($size === self::UNSIGNED_INT32_LENGTH) {
            return $this->readInt32Be();
        }
        if ($size === self::UNSIGNED_INT40_LENGTH) {
            return $this->readInt40Be();
        }

        throw new BinaryDataReaderException('$size ' . $size . ' not handled');
    }
1304297
public BigInteger toBigInteger() {
        byte[] magnitude = new byte[nWords * 4 + 1];
        for (int i = 0; i < nWords; i++) {
            int w = data[i];
            magnitude[magnitude.length - 4 * i - 1] = (byte) w;
            magnitude[magnitude.length - 4 * i - 2] = (byte) (w >> 8);
            magnitude[magnitude.length - 4 * i - 3] = (byte) (w >> 16);
            magnitude[magnitude.length - 4 * i - 4] = (byte) (w >> 24);
        }
        return new BigInteger(magnitude).shiftLeft(offset * 32);
    }
970974
public function toInt()
  {
    if($this->string == pow(2, 63) || $this->string == pow(2, 64))
    {
      return -1;
    }

    return ($this->string > pow(2, 31)) ? floatval($this->string) : intval($this->string);
  }
514194
public function readInt()
    {
        $str = substr($this->_data, $this->_position, 4);
        $this->_position += 4;

        return  ord($str[0]) << 24 |
                ord($str[1]) << 16 |
                ord($str[2]) << 8  |
                ord($str[3]);
    }
1240311
static byte[] toIntegerBytes(final BigInteger bigInt) {
        int bitlen = bigInt.bitLength();
        // round bitlen
        bitlen = ((bitlen + 7) >> 3) << 3;
        final byte[] bigBytes = bigInt.toByteArray();

        if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) {
            return bigBytes;
        }
        // set up params for copying everything but sign bit
        int startSrc = 0;
        int len = bigBytes.length;

        // if bigInt is exactly byte-aligned, just skip signbit in copy
        if ((bigInt.bitLength() % 8) == 0) {
            startSrc = 1;
            len--;
        }
        final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec
        final byte[] resizedBytes = new byte[bitlen / 8];
        System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len);
        return resizedBytes;
    }
233391
public Integer toInteger() {
		Integer value;
		value = Integer.valueOf(this.isNeg ? Integer.parseInt(this.param)*-1 : Integer.parseInt(this.param));
		return value;
	}
652043
private function doGetBinaryBitsetLeInt()
    {
        $bin = \pack(\PHP_INT_SIZE === 8 ? 'P' : 'V', $this->bitset);
        return \substr($bin, 0, (int)\ceil($this->enumerationCount / 8));
    }
419922
public function toBinary()
    {
        $bytes = '';

        foreach (str_split($this->value, 8) as $piece) {
            $bytes .= chr(bindec($piece));
        }

        return $bytes;
    }
658463
function abs()
    {
        $temp = new static();

        switch (MATH_BIGINTEGER_MODE) {
            case self::MODE_GMP:
                $temp->value = gmp_abs($this->value);
                break;
            case self::MODE_BCMATH:
                $temp->value = (bccomp($this->value, '0', 0) < 0) ? substr($this->value, 1) : $this->value;
                break;
            default:
                $temp->value = $this->value;
        }

        return $temp;
    }
1213537
public function bitwiseAnd($x)
    {
        switch (MATH_BIGINTEGER_MODE) {
            case MATH_BIGINTEGER_MODE_GMP:
                $temp = new BigInteger();
                $temp->value = gmp_and($this->value, $x->value);

                return $this->protectedNormalize($temp);
            case MATH_BIGINTEGER_MODE_BCMATH:
                $left = $this->toBytes();
                $right = $x->toBytes();

                $length = max(strlen($left), strlen($right));

                $left = str_pad($left, $length, chr(0), STR_PAD_LEFT);
                $right = str_pad($right, $length, chr(0), STR_PAD_LEFT);

                return $this->protectedNormalize(new BigInteger($left & $right, 256));
        }

        $result = $this->copy();

        $length = min(count($x->value), count($this->value));

        $result->value = array_slice($result->value, 0, $length);

        for ($i = 0; $i < $length; ++ $i) {
            $result->value[$i] &= $x->value[$i];
        }

        return $this->protectedNormalize($result);
    }
276038
private BigInteger toBigInteger(ByteBuffer bb, int significantBytes) {
    byte[] bytes = Bytes.getArray(bb);
    byte[] target;
    if (significantBytes != bytes.length) {
      target = new byte[significantBytes];
      System.arraycopy(bytes, 0, target, 0, bytes.length);
    } else {
      target = bytes;
    }
    return new BigInteger(1, target);
  }
1200891
private function parseSignedInt8()
    {
        try {
            $result = \ord($this->buffer);

            if ($result & 0x80) {
                return $result - 0x100;
            }

            return $result;
        } finally {
            $this->buffer = mb_orig_substr($this->buffer, 1);
        }
    }
96576
function binaryToLong($str)
    {
        if ($str === null) {
            return null;
        }

        // Use array_merge to return a zero-indexed array instead of a
        // one-indexed array.
        $bytes = array_merge(unpack('C*', $str));

        $n = $this->init(0);

        if ($bytes && ($bytes[0] > 127)) {
            trigger_error("bytesToNum works only for positive integers.",
                          E_USER_WARNING);
            return null;
        }

        foreach ($bytes as $byte) {
            $n = $this->mul($n, pow(2, 8));
            $n = $this->add($n, $byte);
        }

        return $n;
    }
257554
public BigInteger readMPINT32() throws IOException {
		int bits = (int) readInt();

		byte[] raw = new byte[(bits + 7) / 8 + 1];

		raw[0] = 0;
		readFully(raw, 1, raw.length - 1);

		return new BigInteger(raw);

	}
1046996
private long convertToLong(byte[] bin){
        ByteBuffer bb = ByteBuffer.wrap(bin);
        bb.order(ByteOrder.BIG_ENDIAN);
        return bb.getInt();
    }