protected function sphPackI64($v)
    {
        assert(is_numeric($v));

        // x64
        if (PHP_INT_SIZE >= 8) {
            $v = (int) $v;

            return pack('NN', $v >> 32, $v & 0xFFFFFFFF);
        }

        // x32, int
        if (is_int($v)) {
            return pack('NN', $v < 0 ? -1 : 0, $v);
        }

        // x32, bcmath
        if (function_exists('bcmul')) {
            if (bccomp($v, 0) == -1) {
                $v = bcadd('18446744073709551616', $v);
            }
            $h = bcdiv($v, '4294967296', 0);
            $l = bcmod($v, '4294967296');

            return pack('NN', (float) $h, (float) $l); // conversion to float is intentional; int would lose 31st bit
        }

        // x32, no-bcmath
        $p = max(0, strlen($v) - 13);
        $lo = abs((float) substr($v, $p));
        $hi = abs((float) substr($v, 0, $p));

        $m = $lo + $hi * 1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912
        $q = floor($m / 4294967296.0);
        $l = $m - ($q * 4294967296.0);
        $h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328

        if ($v < 0) {
            if ($l == 0) {
                $h = 4294967296.0 - $h;
            } else {
                $h = 4294967295.0 - $h;
                $l = 4294967296.0 - $l;
            }
        }

        return pack('NN', $h, $l);
    }
protected function sphPackI64($v)
    {
        assert(is_numeric($v));

        // x64
        if (PHP_INT_SIZE >= 8) {
            $v = (int) $v;

            return pack('NN', $v >> 32, $v & 0xFFFFFFFF);
        }

        // x32, int
        if (is_int($v)) {
            return pack('NN', $v < 0 ? -1 : 0, $v);
        }

        // x32, bcmath
        if (function_exists('bcmul')) {
            if (bccomp($v, 0) == -1) {
                $v = bcadd('18446744073709551616', $v);
            }
            $h = bcdiv($v, '4294967296', 0);
            $l = bcmod($v, '4294967296');

            return pack('NN', (float) $h, (float) $l); // conversion to float is intentional; int would lose 31st bit
        }

        // x32, no-bcmath
        $p = max(0, strlen($v) - 13);
        $lo = abs((float) substr($v, $p));
        $hi = abs((float) substr($v, 0, $p));

        $m = $lo + $hi * 1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912
        $q = floor($m / 4294967296.0);
        $l = $m - ($q * 4294967296.0);
        $h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328

        if ($v < 0) {
            if ($l == 0) {
                $h = 4294967296.0 - $h;
            } else {
                $h = 4294967295.0 - $h;
                $l = 4294967296.0 - $l;
            }
        }

        return pack('NN', $h, $l);
    }
protected function sphPackI64 ( $ v ) { assert ( is_numeric ( $ v ) ) ; // x64 if ( PHP_INT_SIZE >= 8 ) { $ v = ( int ) $ v ; return pack ( 'NN' , $ v >> 32 , $ v & 0xFFFFFFFF ) ; } // x32, int if ( is_int ( $ v ) ) { return pack ( 'NN' , $ v < 0 ? - 1 : 0 , $ v ) ; } // x32, bcmath if ( function_exists ( 'bcmul' ) ) { if ( bccomp ( $ v , 0 ) == - 1 ) { $ v = bcadd ( '18446744073709551616' , $ v ) ; } $ h = bcdiv ( $ v , '4294967296' , 0 ) ; $ l = bcmod ( $ v , '4294967296' ) ; return pack ( 'NN' , ( float ) $ h , ( float ) $ l ) ; // conversion to float is intentional; int would lose 31st bit } // x32, no-bcmath $ p = max ( 0 , strlen ( $ v ) - 13 ) ; $ lo = abs ( ( float ) substr ( $ v , $ p ) ) ; $ hi = abs ( ( float ) substr ( $ v , 0 , $ p ) ) ; $ m = $ lo + $ hi * 1316134912.0 ; // (10 ^ 13) % (1 << 32) = 1316134912 $ q = floor ( $ m / 4294967296.0 ) ; $ l = $ m - ( $ q * 4294967296.0 ) ; $ h = $ hi * 2328.0 + $ q ; // (10 ^ 13) / (1 << 32) = 2328 if ( $ v < 0 ) { if ( $ l == 0 ) { $ h = 4294967296.0 - $ h ; } else { $ h = 4294967295.0 - $ h ; $ l = 4294967296.0 - $ l ; } } return pack ( 'NN' , $ h , $ l ) ; }
Pack 64-bit signed.

@param $v

@return string
Pack 64 - bit signed .