function longToBinary($long)
    {
        $cmp = $this->cmp($long, 0);
        if ($cmp < 0) {
            $msg = __FUNCTION__ . " takes only positive integers.";
            trigger_error($msg, E_USER_ERROR);
            return null;
        }

        if ($cmp == 0) {
            return "\x00";
        }

        $bytes = array();

        while ($this->cmp($long, 0) > 0) {
            array_unshift($bytes, $this->mod($long, 256));
            $long = $this->div($long, pow(2, 8));
        }

        if ($bytes && ($bytes[0] > 127)) {
            array_unshift($bytes, 0);
        }

        $string = '';
        foreach ($bytes as $byte) {
            $string .= pack('C', $byte);
        }

        return $string;
    }
function longToBinary($long)
    {
        $cmp = $this->cmp($long, 0);
        if ($cmp < 0) {
            $msg = __FUNCTION__ . " takes only positive integers.";
            trigger_error($msg, E_USER_ERROR);
            return null;
        }

        if ($cmp == 0) {
            return "\x00";
        }

        $bytes = array();

        while ($this->cmp($long, 0) > 0) {
            array_unshift($bytes, $this->mod($long, 256));
            $long = $this->div($long, pow(2, 8));
        }

        if ($bytes && ($bytes[0] > 127)) {
            array_unshift($bytes, 0);
        }

        $string = '';
        foreach ($bytes as $byte) {
            $string .= pack('C', $byte);
        }

        return $string;
    }
function longToBinary ( $ long ) { $ cmp = $ this -> cmp ( $ long , 0 ) ; if ( $ cmp < 0 ) { $ msg = __FUNCTION__ . " takes only positive integers." ; trigger_error ( $ msg , E_USER_ERROR ) ; return null ; } if ( $ cmp == 0 ) { return "\x00" ; } $ bytes = array ( ) ; while ( $ this -> cmp ( $ long , 0 ) > 0 ) { array_unshift ( $ bytes , $ this -> mod ( $ long , 256 ) ) ; $ long = $ this -> div ( $ long , pow ( 2 , 8 ) ) ; } if ( $ bytes && ( $ bytes [ 0 ] > 127 ) ) { array_unshift ( $ bytes , 0 ) ; } $ string = '' ; foreach ( $ bytes as $ byte ) { $ string .= pack ( 'C' , $ byte ) ; } return $ string ; }
Given a long integer, returns the number converted to a binary
string.  This function accepts long integer values of arbitrary
magnitude and uses the local large-number math library when
available.

@param integer $long The long number (can be a normal PHP
integer or a number created by one of the available long number
libraries)
@return string $binary The binary version of $long
Given a long integer returns the number converted to a binary string . This function accepts long integer values of arbitrary magnitude and uses the local large - number math library when available .