public Text evaluate(Text n, IntWritable fromBase, IntWritable toBase) {
    if (n == null || fromBase == null || toBase == null) {
      return null;
    }

    int fromBs = fromBase.get();
    int toBs = toBase.get();
    if (fromBs < Character.MIN_RADIX || fromBs > Character.MAX_RADIX
        || Math.abs(toBs) < Character.MIN_RADIX
        || Math.abs(toBs) > Character.MAX_RADIX) {
      return null;
    }

    byte[] num = n.getBytes();
    if (num.length == 0) {
      return null;
    }
    boolean negative = (num[0] == '-');
    int first = 0;
    if (negative) {
      first = 1;
    }

    // Copy the digits in the right side of the array
    for (int i = 1; i <= n.getLength() - first; i++) {
      value[value.length - i] = num[n.getLength() - i];
    }
    char2byte(fromBs, value.length - n.getLength() + first);

    // Do the conversion by going through a 64 bit integer
    long val = encode(fromBs, value.length - n.getLength() + first);
    if (negative && toBs > 0) {
      if (val < 0) {
        val = -1;
      } else {
        val = -val;
      }
    }
    if (toBs < 0 && val < 0) {
      val = -val;
      negative = true;
    }
    decode(val, Math.abs(toBs));

    // Find the first non-zero digit or the last digits if all are zero.
    for (first = 0; first < value.length - 1 && value[first] == 0; first++) {
      ;
    }

    byte2char(Math.abs(toBs), first);

    if (negative && toBs < 0) {
      value[--first] = '-';
    }

    result.set(value, first, value.length - first);
    return result;
  }
Convert numbers between different number bases. If toBase&gt;0 the result is
unsigned, otherwise it is signed.
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFConv.java