class NumberUtils {

  private static BigInteger decodeBigInteger(final String value) {
    int radix = 10;
    int index = 0;
    boolean negative = false;

    // Handle minus sign, if present.
    if (value.startsWith("-")) {
      negative = true;
      ++index;
    }

    // Handle radix specifier, if present.
    if (value.startsWith("0x", index) || value.startsWith("0X", index)) {
      index += 2;
      radix = 16;
    } else if (value.startsWith("#", index)) {
      ++index;
      radix = 16;
    } else if (value.startsWith("0", index) && 1 + index < value.length()) {
      ++index;
      radix = 8;
    }

    final BigInteger result = new BigInteger(value.substring(index), radix);
    return (negative ? result.negate() : result);
  }

}