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;
    }
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;
    }
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 ; }
Given a binary string, returns the binary string converted to a
long number.

@param string $str The binary version of a long number,
probably as a result of calling longToBinary
@return integer $long The long number equivalent of the binary
string $str
Given a binary string returns the binary string converted to a long number .