public static function decodeSigned(string $buf, int &$x): int
    {
        $ux = 0;
        $cnt = self::decodeUnsigned($buf, $ux);
        $x = $ux >> 1;
        if ($ux&1 != 0) {
            $x = ~$x;
        }
        return $cnt;
    }