public static long parseDigits(final String text, final int bitsInRadix, final int maxBits) throws NumberFormatException {
    final int textLength = text.length();
    if (textLength == 0) {
      throw new NumberFormatException(text);
    }
    final int radix = 1 << bitsInRadix;
    long integer = textLength == 1 ? 0 : Long.parseLong(text.substring(0, textLength - 1), radix);
    if ((integer & (-1L << (maxBits - bitsInRadix))) != 0) {
      throw new NumberFormatException(text);
    }
    final int lastDigit = Character.digit(text.charAt(textLength - 1), radix);
    if (lastDigit == -1) {
      throw new NumberFormatException(text);
    }
    integer <<= bitsInRadix;
    integer |= lastDigit;
    return integer;
  }
public static long parseDigits(final String text, final int bitsInRadix, final int maxBits)