static long parseLong(final byte[] buffer, final int start, final int length,
            final int radix, final boolean positive) throws NumberFormatException
    {
        long max = Long.MIN_VALUE / radix;
        long result = 0;
        for (int offset = start, limit = start + length; offset < limit;)
        {
            int digit = Character.digit(buffer[offset++], radix);
            if (digit == -1)
            {
                throw new NumberFormatException(STRING.deser(buffer, start, length));
            }
            if (max > result)
            {
                throw new NumberFormatException(STRING.deser(buffer, start, length));
            }
            long next = result * radix - digit;
            if (next > result)
            {
                throw new NumberFormatException(STRING.deser(buffer, start, length));
            }
            result = next;
        }
        if (positive)
        {
            result = -result;
            if (result < 0)
            {
                throw new NumberFormatException(STRING.deser(buffer, start, length));
            }
        }

        return result;
    }
Parse an ascii long from a raw buffer.
protostuff-api/src/main/java/io/protostuff/NumberParser.java