private long encode(int radix, int fromPos) {
    long val = 0;
    long bound = unsignedLongDiv(-1 - radix, radix); // Possible overflow once
    // val
    // exceeds this value
    for (int i = fromPos; i < value.length && value[i] >= 0; i++) {
      if (val >= bound) {
        // Check for overflow
        if (unsignedLongDiv(-1 - value[i], radix) < val) {
          return -1;
        }
      }
      val = val * radix + value[i];
    }
    return val;
  }
Convert value[] into a long. On overflow, return -1 (as mySQL does). If a
negative digit is found, ignore the suffix starting there.

@param radix
         must be between MIN_RADIX and MAX_RADIX
@param fromPos
         is the first element that should be considered
@return the result should be treated as an unsigned 64-bit integer.
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFConv.java