private static int parse(byte[] bytes, int start, int length, int offset,
      int radix, boolean negative) {
    byte separator = '.';
    int max = Integer.MIN_VALUE / radix;
    int result = 0, end = start + length;
    while (offset < end) {
      int digit = LazyUtils.digit(bytes[offset++], radix);
      if (digit == -1) {
        if (bytes[offset-1] == separator) {
          // We allow decimals and will return a truncated integer in that case.
          // Therefore we won't throw an exception here (checking the fractional
          // part happens below.)
          break;
        }
        throw new NumberFormatException(LazyUtils.convertToString(bytes, start,
            length));
      }
      if (max > result) {
        throw new NumberFormatException(LazyUtils.convertToString(bytes, start,
            length));
      }
      int next = result * radix - digit;
      if (next > result) {
        throw new NumberFormatException(LazyUtils.convertToString(bytes, start,
            length));
      }
      result = next;
    }

    // This is the case when we've encountered a decimal separator. The fractional
    // part will not change the number, but we will verify that the fractional part
    // is well formed.
    while (offset < end) {
      int digit = LazyUtils.digit(bytes[offset++], radix);
      if (digit == -1) {
        throw new NumberFormatException(LazyUtils.convertToString(bytes, start,
            length));
      }
    }

    if (!negative) {
      result = -result;
      if (result < 0) {
        throw new NumberFormatException(LazyUtils.convertToString(bytes, start,
            length));
      }
    }
    return result;
  }
@param bytes
@param start
@param length
         a UTF-8 encoded string representation of an int quantity.
@param radix
         the base to use for conversion.
@param offset
         the starting position after the sign (if exists)
@param radix
         the base to use for conversion.
@param negative
         whether the number is negative.
@return the value represented by the argument
@exception NumberFormatException
             if the argument could not be parsed as an int quantity.
serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyInteger.java